I am using Laravel and need some help migrating a column from a populated table preserving the content logic. There is a table pages
with a column named icon
that accepts string
values.
Ex:
Schema::create('pages', function (Blueprint $table) {
$table->increments('id');
...
$table->string('icon')->nullable();
}
The pages
table is populated and the icon
column, being nullable, is not always used.
A new icons
table was created to store all the usable icon classes.
Ex:
Schema::create('icons', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
});
How can i migrate the icon
column from the pages
table to be a foreign key that points to the icons
table row that has the same value in the name
column or null if not populated?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire