mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
30 lines
819 B
PHP
30 lines
819 B
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class AddClienteIdToEnvios extends Migration
|
|
{
|
|
public function up()
|
|
{
|
|
$this->forge->addColumn('envios', [
|
|
'cliente_id' => [
|
|
'type' => 'INT',
|
|
'constraint' => 11,
|
|
'unsigned' => true, // IMPORTANTE
|
|
'null' => true,
|
|
'after' => 'id',
|
|
],
|
|
]);
|
|
|
|
$this->db->query('ALTER TABLE envios ADD CONSTRAINT fk_envios_cliente FOREIGN KEY (cliente_id) REFERENCES clientes(id) ON DELETE SET NULL ON UPDATE CASCADE');
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
$this->db->query('ALTER TABLE envios DROP FOREIGN KEY fk_envios_cliente');
|
|
$this->forge->dropColumn('envios', 'cliente_id');
|
|
}
|
|
}
|