From 71d10de4c26a0c9f836da668c6f0a068e574cb5e Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Tue, 3 May 2022 15:03:28 +0800 Subject: [PATCH] add times field to magic table --- ..._145712_add_times_field_to_magic_table.php | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 database/migrations/2022_05_03_145712_add_times_field_to_magic_table.php diff --git a/database/migrations/2022_05_03_145712_add_times_field_to_magic_table.php b/database/migrations/2022_05_03_145712_add_times_field_to_magic_table.php new file mode 100644 index 00000000..a97f7f23 --- /dev/null +++ b/database/migrations/2022_05_03_145712_add_times_field_to_magic_table.php @@ -0,0 +1,37 @@ +dateTime('created_at')->useCurrent(); + } + if (!Schema::hasColumn('magic', 'updated_at')) { + $table->dateTime('updated_at')->useCurrent()->useCurrentOnUpdate(); + } + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('magic', function (Blueprint $table) { + $table->dropColumn(['created_at', 'updated_at']); + }); + } +};