mardi 17 juillet 2018

How to transform an existing column in foreign key using Laravel Migrations

i'm having trouble trying to change a column type in laravel to fits it as a compatible column to be a foreign key referencing another table id fields.

Actualy i have a a schema like this:

Schema::create('persons', function(Blueprint $table){
   ...

   $table->integer('organization_id');
   ...
});

and i want to change the field organization_id to an unsigned type, wich will make it able to be a foreign key referencing the id field in the organizations table.

NOTE: Just changing the field type in the creation of the table is not an available option, because the system is running in production mode.

So we need to make a new migration to do these changes.

NOTE 2: i tried the method change as described in laravel docs, but it stucks in a query error.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire