I have the following migration:
Schema::create('items', function(Blueprint $table) {
$table->uuid('id')->primary();
// more columns ...
});
Now, we want to add an additional auto-increment column:
Schema::table('items', function(Blueprint $table) {
$table->dropPrimary('id');
$table->rename('id', 'SystemId')->change();
$table->id();
});
Problem: SQLite doesn't allow changing the primary key
Solution: It's recommended to delete the table and create it with the changed schema
Of course, that works in theory but it is anything but DRY to copy the code from our first migration to our second. So my question is: Is there another way to achieve this?