feat : chat migrations

This commit is contained in:
amazuecos
2024-09-20 08:54:43 +02:00
parent f8dd56b74c
commit b25abc19d9
5 changed files with 27 additions and 8 deletions

View File

@ -0,0 +1,63 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\RawSql;
use CodeIgniter\Database\Migration;
class ChatsTable extends Migration
{
protected array $COLUMNS = [
"id" => [
"type" => "INT",
"unsigned" => true,
"autoincrement" => true
],
"chat_department_id" => [
"type" => "INT",
"unsigned" => true,
],
"pedido_id" => [
"type" => "INT",
"constraint" => 16,
"unsigned" => true,
],
];
public function up()
{
$this->forge->dropTable("chat_conversaciones",true);
$this->forge->dropTable("chat_mensajes",true);
$this->forge->dropTable("chat_participantes",true);
$this->forge->addField($this->COLUMNS);
$currenttime = new RawSql("CURRENT_TIMESTAMP");
$this->forge->addField([
"created_at" => [
"type" => "TIMESTAMP",
"default" => $currenttime,
],
"updated_at" => [
"type" => "TIMESTAMP",
"nullable" => true,
],
"deleted_at" => [
"type" => "TIMESTAMP",
"nullable" => true,
],
]);
$this->forge->addPrimaryKey('id');
$this->forge->addForeignKey('pedido_id', 'pedidos', 'id');
// $this->forge->addForeignKey('chat_department_id', 'chat_departments', 'id');
$this->forge->createTable("chats",true);
}
public function down()
{
//
$this->forge->dropTable("chats",true);
}
}