From d8acdce6e252909f77d27c932fde337c537ebf0c Mon Sep 17 00:00:00 2001 From: "iVampireSP.com" Date: Mon, 13 Feb 2023 02:41:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=A8=E6=9C=9F=E6=80=A7=E8=AE=A1=E8=B4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...33014_add_billing_cycle_to_hosts_table.php | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 database/migrations/2023_02_12_233014_add_billing_cycle_to_hosts_table.php diff --git a/database/migrations/2023_02_12_233014_add_billing_cycle_to_hosts_table.php b/database/migrations/2023_02_12_233014_add_billing_cycle_to_hosts_table.php new file mode 100644 index 0000000..3e61a75 --- /dev/null +++ b/database/migrations/2023_02_12_233014_add_billing_cycle_to_hosts_table.php @@ -0,0 +1,48 @@ +enum('billing_cycle', [ + 'monthly', + 'quarterly', + 'semi-annually', + 'annually', + 'biennially', + 'triennially', + ])->nullable()->index()->after('status'); + + $table->dateTime('next_due_at')->nullable()->after('billing_cycle')->index(); + }); + + $raw = \Illuminate\Support\Facades\DB::raw("ALTER TABLE `hosts` CHANGE `status` `status` ENUM('draft', 'running','stopped','error','suspended','pending','unavailable','locked') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending';"); + \Illuminate\Support\Facades\DB::statement($raw); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down(): void + { + Schema::table('hosts', function (Blueprint $table) { + $table->dropColumn('billing_cycle'); + $table->dropColumn('next_due_at'); + }); + + $raw = \Illuminate\Support\Facades\DB::raw("ALTER TABLE `hosts` CHANGE `status` `status` ENUM('running','stopped','error','suspended','pending','unavailable','locked') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending';"); + \Illuminate\Support\Facades\DB::statement($raw); + } +};