From d10d3ddd9264c30590fd968d4db2192e1658147f Mon Sep 17 00:00:00 2001 From: Leonard Smith Date: Sat, 1 May 2021 16:34:49 -0500 Subject: [PATCH] Modify the type of the primary key on the words table --- ...51109_alter_primary_key_on_words_table.php | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 database/migrations/2021_05_01_151109_alter_primary_key_on_words_table.php diff --git a/database/migrations/2021_05_01_151109_alter_primary_key_on_words_table.php b/database/migrations/2021_05_01_151109_alter_primary_key_on_words_table.php new file mode 100644 index 0000000..5855554 --- /dev/null +++ b/database/migrations/2021_05_01_151109_alter_primary_key_on_words_table.php @@ -0,0 +1,47 @@ +dropColumn('id'); + }); + + Schema::table('words', function (Blueprint $table) { + $table->bigIncrements('id')->first(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('words', function (Blueprint $table) { + $table->dropColumn('id'); + }); + + /** + * @NOTE: The below does not work if data is in the table. + * The IDs will need to be recreated and then + * the primary key index can be re-added. Given that our DB gets repopulated + * on import commands, we can handle that later, OR truncate the table, add the + * primary key index, and then re-run the imports. Baker's choice. + */ + Schema::table('words', function (Blueprint $table) { + $table->string('id')->primary()->first(); + }); + } +}