Skip to content

Table migrations missing column id #39473

Answered by MircoBabin
MircoBabin asked this question in Q&A
Discussion options

You must be logged in to vote

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) {
 …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by MircoBabin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants