浏览代码

feat: drop deprecated user_invite_code values

M1Screw 1 年之前
父节点
当前提交
5e82c443f7

+ 6 - 6
composer.lock

@@ -123,16 +123,16 @@
         },
         {
             "name": "aws/aws-sdk-php",
-            "version": "3.286.3",
+            "version": "3.287.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/aws/aws-sdk-php.git",
-                "reference": "29079a62c6a30ac594b50285494b4dec279b4648"
+                "reference": "06978bfc63111fccd78b364238bf214b4ade8d18"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/29079a62c6a30ac594b50285494b4dec279b4648",
-                "reference": "29079a62c6a30ac594b50285494b4dec279b4648",
+                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/06978bfc63111fccd78b364238bf214b4ade8d18",
+                "reference": "06978bfc63111fccd78b364238bf214b4ade8d18",
                 "shasum": ""
             },
             "require": {
@@ -212,9 +212,9 @@
             "support": {
                 "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
                 "issues": "https://github.com/aws/aws-sdk-php/issues",
-                "source": "https://github.com/aws/aws-sdk-php/tree/3.286.3"
+                "source": "https://github.com/aws/aws-sdk-php/tree/3.287.0"
             },
-            "time": "2023-11-16T19:12:53+00:00"
+            "time": "2023-11-17T20:03:36+00:00"
         },
         {
             "name": "bacon/bacon-qr-code",

+ 0 - 2
db/migrations/2023020100-init.php

@@ -347,8 +347,6 @@ return new class() implements MigrationInterface {
                 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '记录ID',
                 `code` varchar(255) NOT NULL DEFAULT '' COMMENT '邀请码',
                 `user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户ID',
-                `created_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT '创建时间',
-                `updated_at` timestamp NOT NULL DEFAULT '1989-06-04 00:05:00' COMMENT '更新时间',
                 PRIMARY KEY (`id`),
                 UNIQUE KEY `code` (`code`),
                 UNIQUE KEY `user_id` (`user_id`)

+ 0 - 2
db/migrations/2023061800-update_new_shop_data_type.php

@@ -163,8 +163,6 @@ return new class() implements MigrationInterface {
         ALTER TABLE user_invite_code MODIFY COLUMN `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '记录ID';
         ALTER TABLE user_invite_code MODIFY COLUMN `code` varchar(255) NOT NULL DEFAULT '' COMMENT '邀请码';
         ALTER TABLE user_invite_code MODIFY COLUMN `user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户ID';
-        ALTER TABLE user_invite_code MODIFY COLUMN `created_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT '创建时间';
-        ALTER TABLE user_invite_code MODIFY COLUMN `updated_at` timestamp NOT NULL DEFAULT '1989-06-04 00:05:00' COMMENT '更新时间';
         ALTER TABLE user_money_log MODIFY COLUMN `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '记录ID';
         SET FOREIGN_KEY_CHECKS = 1;");
 

+ 28 - 0
db/migrations/2023111800-remove_user_invite_code_at.php

@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+
+use App\Interfaces\MigrationInterface;
+use App\Services\DB;
+
+return new class() implements MigrationInterface {
+    public function up(): int
+    {
+        DB::getPdo()->exec('
+            ALTER TABLE user_invite_code DROP COLUMN IF EXISTS `created_at`;
+            ALTER TABLE user_invite_code DROP COLUMN IF EXISTS `updated_at`;
+        ');
+
+        return 2023111800;
+    }
+
+    public function down(): int
+    {
+        DB::getPdo()->exec("
+            ALTER TABLE user_invite_code ADD COLUMN IF NOT EXISTS `created_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT '创建时间';
+            ALTER TABLE user_invite_code ADD COLUMN IF NOT EXISTS `updated_at` timestamp NOT NULL DEFAULT '1989-06-04 00:05:00' COMMENT '更新时间';
+        ");
+
+        return 2023111700;
+    }
+};

+ 9 - 11
src/Controllers/Admin/NodeController.php

@@ -296,19 +296,17 @@ final class NodeController extends BaseController
 
     public function copy($request, $response, $args)
     {
-        try {
-            $old_node = Node::find($args['id']);
-            $new_node = new Node();
-            $new_node = $old_node->replicate([
-                'node_bandwidth',
-            ]);
-            $new_node->name .= ' (副本)';
-            $new_node->node_bandwidth = 0;
-            $new_node->save();
-        } catch (Exception $e) {
+        $old_node = Node::find($args['id']);
+        $new_node = $old_node->replicate([
+            'node_bandwidth',
+        ]);
+        $new_node->name .= ' (副本)';
+        $new_node->node_bandwidth = 0;
+
+        if (! $new_node->save()) {
             return $response->withJson([
                 'ret' => 0,
-                'msg' => $e->getMessage(),
+                'msg' => '复制失败',
             ]);
         }
 

+ 0 - 3
src/Models/InviteCode.php

@@ -11,9 +11,6 @@ use Illuminate\Database\Query\Builder;
  * @property int    $id         记录ID
  * @property string $code       邀请码
  * @property int    $user_id    用户ID
- * todo: delete these two properties
- * @property int    $create_at  创建时间
- * @property int    $updated_at 更新时间
  *
  * @mixin Builder
  */