Table migrations
missing column id
#39473
-
Dear reader, Today I noticed that older installations (originating from Laravel 4.2) are missing the I found the creation of the The I have read the upgrade notes for Laravel 5.3, but there is no mention of a change in the Does anybody with an elephant history recall if any migration exists or is documented somewhere how to add the P.S. this project was shifted to Laravel 7.x (current version) and will shift to Laravel 9.x (LTS) when it comes available. Kind Regards, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
This shouldn't be a problem, the If it really bugs you, you can manually add the |
Beta Was this translation helpful? Give feedback.
-
Thanks for your reply @dennisprudlo . It bugs me, I want all databases to have same table layout. So I created a migration that at least works on MySql. 2021_11_15_070000_update_migrations_id.php <?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateMigrationsId extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (Schema::hasColumn('migrations', 'id')) {
return;
}
//create `migrations`.`id` as first field, before `migration`
Schema::table('migrations', function ($table) {
$table->increments('id')->first();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
if (Schema::hasColumn('migrations', 'id')) {
Schema::table('migrations', function ($table) {
$table->dropColumn('id');
});
}
}
} |
Beta Was this translation helpful? Give feedback.
Thanks for your reply @dennisprudlo .
It bugs me, I want all databases to have same table layout. So I created a migration that at least works on MySql.
2021_11_15_070000_update_migrations_id.php