Browse Source

fix: migrate error

https://github.com/Anankke/SSPanel-Uim/issues/1524
Cat 3 years ago
parent
commit
f2e5a1bc09

+ 1 - 1
Dockerfile

@@ -9,7 +9,7 @@ RUN cp config/.config.example.php "config/.config.php" && \
     chmod -R 755 storage && \
     chmod -R 777 /var/www/storage/framework/smarty/compile/ && \
     mv db/migrations/20000101000000_init_database.php.new db/migrations/20000101000000_init_database.php && \
-    wget https://getcomposer.org/installer -O composer.phar && \
+    curl -SL https://getcomposer.org/installer -o composer.phar && \
     php composer.phar && \
     php composer.phar install && \
     php vendor/bin/phinx migrate && \

+ 3 - 1
db/migrations/20220814175532_drop_g_config_table.php

@@ -8,7 +8,9 @@ final class DropGConfigTable extends AbstractMigration
 {
     public function up(): void
     {
-        $this->table('gconfig')->drop()->update();
+        if ($this->hasTable('gconfig')) {
+            $this->table('gconfig')->drop()->update();
+        }
     }
 
     public function down(): void

+ 0 - 0
install.sh


+ 0 - 0
utils/block-whoops-env.sh → scripts/block-whoops-env.sh


+ 0 - 0
upgrade.sh


+ 0 - 154
utils/clean_job.php

@@ -1,154 +0,0 @@
-#!/usr/bin/env php
-<?php
-
-declare(strict_types=1);
-
-use App\Services\Boot;
-
-require __DIR__ . '/../app/predefine.php';
-require __DIR__ . '/../vendor/autoload.php';
-require __DIR__ . '/../config/.config.php';
-
-Boot::setTime();
-Boot::bootDb();
-
-$processed = [];
-$renew = [];
-$renew_c = static function ($ids) use ($processed): void {
-    echo 'Renew Process START.';
-    foreach ($ids as $id) {
-        $bought = \App\Models\Bought::find($id);
-        if ($bought === null) {
-            echo 'Bought not found:' . $id . PHP_EOL;
-            unlink(__DIR__ . '/../storage/' . $id . '.renew');
-            $processed['renew'] = $id;
-        } else {
-            $bought->is_notified = true;
-            if ($bought->save() === true) {
-                unlink(__DIR__ . '/../storage/' . $id . '.renew');
-                echo 'Renew Process successed for bought' . $id . PHP_EOL;
-                $processed['renew'] = $id;
-            }
-        }
-    }
-    echo 'Renew Process END.' . PHP_EOL . PHP_EOL;
-};
-
-$offline = [];
-$offline_c = static function ($ids) use ($processed): void {
-    echo 'Offline Process START.';
-    foreach ($ids as $id) {
-        $node = \App\Models\Node::find($id);
-        if ($node === null) {
-            echo 'Node not found:' . $id . PHP_EOL;
-            unlink(__DIR__ . '/../storage/' . $id . '.offline');
-            $processed['offline'] = $id;
-        } else {
-            $node->online = false;
-            if ($node->save() === true) {
-                unlink(__DIR__ . '/../storage/' . $id . '.offline');
-                echo 'Offline Process successed for node' . $id . PHP_EOL;
-                $processed['offline'] = $id;
-            }
-        }
-    }
-    echo 'Offline Process END.' . PHP_EOL . PHP_EOL;
-};
-
-$expire = [];
-$expire_c = static function ($ids) use ($processed): void {
-    echo 'Expire Process START.';
-    foreach ($ids as $id) {
-        $user = \App\Models\User::find($id);
-        if ($user === null) {
-            echo 'User not found:' . $id . PHP_EOL;
-            unlink(__DIR__ . '/../storage/' . $id . '.expire_in');
-            $processed['expire'] = $id;
-        } else {
-            $user->expire_notified = true;
-            if ($user->save() === true) {
-                unlink(__DIR__ . '/../storage/' . $id . '.expire_in');
-                echo 'Expire Process successed for user' . $id . PHP_EOL;
-                $processed['expire'] = $id;
-            }
-        }
-    }
-    echo 'Expire Process END.' . PHP_EOL . PHP_EOL;
-};
-
-$gfw = [];
-$gfw_c = static function ($ids) use ($processed): void {
-    echo 'GFW Process START.';
-    foreach ($ids as $id) {
-        $node = \App\Models\Node::find($id);
-        if ($node === null) {
-            echo 'Node not found:' . $id . PHP_EOL;
-            unlink(__DIR__ . '/../storage/' . $id . '.gfw');
-            $processed['gfw'] = $id;
-        } else {
-            $node->gfw_block = true;
-            if ($node->save() === true) {
-                unlink(__DIR__ . '/../storage/' . $id . '.gfw');
-                echo 'GFW Process successed for node' . $id . PHP_EOL;
-                $processed['gfw'] = $id;
-            }
-        }
-    }
-    echo 'GFW Process END.' . PHP_EOL . PHP_EOL;
-};
-
-$files = scandir(__DIR__ . '/../storage');
-foreach ($files as $origin_file) {
-    $file = explode('.', $origin_file);
-    if (count($file) === 2 && is_numeric($file[0])) {
-        switch ($file[1]) {
-            case 'renew':
-                $renew[] = $file[0];
-                break;
-            case 'offline':
-                $offline[] = $file[0];
-                break;
-            case 'expire_in':
-                $expire[] = $file[0];
-                break;
-            case 'gfw':
-                $gfw[] = $file[0];
-                break;
-            default:
-                echo 'Unrecognized file: ' . $origin_file . PHP_EOL;
-        }
-    } else {
-        continue;
-    }
-}
-
-$renew_c($renew);
-$offline_c($offline);
-$expire_c($expire);
-$gfw_c($gfw);
-
-if (file_exists(__DIR__ . '/../storage/traffic_notified') === true) {
-    $files = scandir(__DIR__ . '/../storage/traffic_notified');
-    if ($files !== false) {
-        $notified = [];
-        foreach ($files as $origin_file) {
-            $file = explode('.', $origin_file);
-            if (count($file) === 2 && is_numeric($file[0] && $file[1] === 'userid')) {
-                $notified[] = $file[0];
-            } else {
-                echo 'Unrecognized file: ' . $origin_file . PHP_EOL;
-            }
-        }
-        file_put_contents(__DIR__ . '/notified.json', json_encode($file));
-    }
-} else {
-    echo 'Notified Process Nothing to do.' . PHP_EOL . PHP_EOL;
-}
-file_put_contents(__DIR__ . '/processed.json', json_encode($processed));
-file_put_contents(__DIR__ . '/raw.json', json_encode([
-    'renew' => $renew,
-    'offline' => $offline,
-    'expire' => $expire,
-    'gfw' => $gfw,
-]));
-exit(0);

+ 0 - 49
utils/clean_link.php

@@ -1,49 +0,0 @@
-#!/usr/bin/env php
-<?php
-
-declare(strict_types=1);
-
-use App\Models\Link;
-use App\Services\Boot;
-use Illuminate\Database\Capsule\Manager as Capsule;
-use Illuminate\Database\Schema\Blueprint;
-
-require __DIR__ . '/../app/predefine.php';
-require __DIR__ . '/../vendor/autoload.php';
-require __DIR__ . '/../config/.config.php';
-
-Boot::setTime();
-Boot::bootDb();
-
-echo PHP_EOL;
-
-try {
-    Link::where('type', '<>', 11)->delete();
-    echo '所有类型非 11 的订阅链接已全部清理.' . PHP_EOL;
-} catch (\Throwable $th) {
-    $th->getMessage();
-}
-
-try {
-    Capsule::schema()->table(
-        'link',
-        static function (Blueprint $table): void {
-            $table->dropColumn(
-                [
-                    'type',
-                    'address',
-                    'port',
-                    'ios',
-                    'isp',
-                    'geo',
-                    'method',
-                ]
-            );
-        }
-    );
-    echo 'link 表无用的字段已全部清理.' . PHP_EOL;
-} catch (\Throwable $th) {
-    $th->getMessage();
-}
-
-exit(0);