Files
safekat/ci4/app/Database/Migrations/2025-03-17-080000_AddForeignChatDepartmentUsers.php
2025-04-21 12:55:45 +02:00

46 lines
1.3 KiB
PHP
Executable File

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use CodeIgniter\Database\RawSql;
class AddForeignChatDepartmentUsers extends Migration
{
protected array $COLUMNS = [
"pedido_id" => [
"type" => "INT",
"constraint" => 16,
"unsigned" => true,
"null" => true
],
"presupuesto_id" => [
"type" => "INT",
"constraint" => 10,
"unsigned" => true,
"null" => true
],
"factura_id" => [
"type" => "INT",
"constraint" => 10,
"unsigned" => true,
"null" => true
],
];
public function up()
{
$this->forge->addColumn("chat_department_users",$this->COLUMNS);
$this->forge->addForeignKey('pedido_id', 'pedidos', 'id');
$this->forge->addForeignKey('factura_id', 'facturas', 'id');
$this->forge->addForeignKey('presupuesto_id', 'presupuestos', 'id');
}
public function down()
{
$this->forge->dropForeignKey("chat_department_users","pedido_id");
$this->forge->dropForeignKey("chat_department_users","factura_id");
$this->forge->dropForeignKey("chat_department_users","presupuesto_id");
$this->forge->dropColumn("chat_department_users",["pedido_id","factura_id","presupuesto_id"]);
}
}