Modify the type of the primary key on the words table
This commit is contained in:
parent
a528ce9f96
commit
d10d3ddd92
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AlterPrimaryKeyOnWordsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('words', function (Blueprint $table) {
|
||||
$table->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();
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue