dimanche 14 mars 2021

Using Laravel 5.5 how do I duplicate a column in a table with a migration?

I would like to duplicate a column on my existing seasons table using a migration in Laravel 5.5.

I can do it using SQL running these two queries:

ALTER TABLE seasons ADD uploader_channel_partner_id BIGINT NULL 

then

UPDATE seasons set seasons.uploader_channel_partner_id = seasons.channel_partner_id

I am creating a system where you can transfer the ownership of videos while keeping the original uploader stored.

The up function of my migration currently just has this inside it:

Schema::create('seasons', function (Blueprint $table) {
    $table->unsignedBigInteger('uploader_channel_partner_id');
    $table->foreign('uploader_channel_partner_id')->references('id')->on('channel_partners');
});


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire