From 15cd56aae18d50fcc9e41ab16fa64e288f78044f Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Thu, 26 Mar 2020 01:37:39 +0100 Subject: [PATCH] Add order column to twofaccounts table --- ...add_order_column_to_twofaccounts_table.php | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 database/migrations/2020_03_25_095517_add_order_column_to_twofaccounts_table.php diff --git a/database/migrations/2020_03_25_095517_add_order_column_to_twofaccounts_table.php b/database/migrations/2020_03_25_095517_add_order_column_to_twofaccounts_table.php new file mode 100644 index 00000000..21c6488e --- /dev/null +++ b/database/migrations/2020_03_25_095517_add_order_column_to_twofaccounts_table.php @@ -0,0 +1,40 @@ +integer('order_column')->nullable(); + }); + + // The primary index is used to set a default value for the newly + // created order_column + foreach (TwoFAccount::get() as $twofaccount) { + $twofaccount->order_column = $twofaccount->id; + $twofaccount->save(); + } + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('twofaccounts', function (Blueprint $table) { + $table->dropColumn('order_column'); + }); + } +}