Welcome Guest, Not a member yet? Register   Sign In
Migration add field and set as foreign key
#5

(02-27-2024, 02:51 PM)kenjis Wrote: See https://codeigniter.com/user_guide/dbmgm...to-a-table

Code:
<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class RemoveCulumnToAttivitaDelegate extends Migration
{
    public function up()
    {
       
        $this->forge->dropForeignKey('attivita_delegate', 'id_user_ricevente');
       

        $fields = [

            'id_user_ricevente'

        ];
        $this->forge->dropColumn('attivita_delegate', $fields);
       
    }

    public function down()
    {


       
        $fields = [

            'id_user_ricevente' =>  [ 
                                'type' => 'int',
                                'constraint' => '100',
                                'unsigned'      => true,
                                'null' => false,
                                'after'=>'id'
                            ],


        ];


        $this->forge->addColumn('attivita_delegate', $fields);


        $this->forge->addForeignKey('attivita_delegate', 'id_user_ricevente');

       
    }
}

Can't DROP 'id_user_ricevente'; check that column/key exists

(the culumn exist)
Reply


Messages In This Thread
RE: Migration add field and set as foreign key - by pippuccio76 - 03-03-2024, 09:19 AM



Theme © iAndrew 2016 - Forum software by © MyBB