From e489f5036b7148adf4ddc0a205393bc0c16a00ce Mon Sep 17 00:00:00 2001 From: Nick Zeng Date: Wed, 4 Feb 2026 12:54:55 +0800 Subject: [PATCH] update orders table --- ...2_04_110000_update_orders_raw_and_hash.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 backend/migrations/2026_02_04_110000_update_orders_raw_and_hash.php diff --git a/backend/migrations/2026_02_04_110000_update_orders_raw_and_hash.php b/backend/migrations/2026_02_04_110000_update_orders_raw_and_hash.php new file mode 100644 index 0000000..9296f3f --- /dev/null +++ b/backend/migrations/2026_02_04_110000_update_orders_raw_and_hash.php @@ -0,0 +1,34 @@ +statement('ALTER TABLE orders RENAME COLUMN raw_hash TO hash'); + + // 将 raw 和 hash 改为非空 + Schema::getConnection()->statement('ALTER TABLE orders ALTER COLUMN raw SET NOT NULL'); + Schema::getConnection()->statement('ALTER TABLE orders ALTER COLUMN hash SET NOT NULL'); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + // 将 raw 和 hash 改回可空 + Schema::getConnection()->statement('ALTER TABLE orders ALTER COLUMN raw DROP NOT NULL'); + Schema::getConnection()->statement('ALTER TABLE orders ALTER COLUMN hash DROP NOT NULL'); + + // 重命名 hash 回 raw_hash + Schema::getConnection()->statement('ALTER TABLE orders RENAME COLUMN hash TO raw_hash'); + } +};