mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
feat : migration and chat models
This commit is contained in:
62
ci4/app/Database/Migrations/2024-09-17-151440_ChatsTable.php
Normal file
62
ci4/app/Database/Migrations/2024-09-17-151440_ChatsTable.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?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,
|
||||
"auto_increment" => 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",
|
||||
"null" => true,
|
||||
],
|
||||
"deleted_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"null" => 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user