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:
@ -11,13 +11,17 @@ class ChatDepartments extends Migration
|
||||
"id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"autoincrement" => true
|
||||
"auto_increment" => true
|
||||
],
|
||||
"name" => [
|
||||
"type" => "VARCHAR",
|
||||
"constraint" => '45',
|
||||
"unique" => true,
|
||||
],
|
||||
"display" => [
|
||||
"type" => "VARCHAR",
|
||||
"constraint" => '255',
|
||||
],
|
||||
|
||||
];
|
||||
public function up()
|
||||
@ -28,22 +32,21 @@ class ChatDepartments extends Migration
|
||||
"created_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"default" => $currenttime,
|
||||
|
||||
|
||||
],
|
||||
"updated_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"nullable" => true,
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
"deleted_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"nullable" => true,
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
]);
|
||||
$this->forge->createTable("chat_departments",true);
|
||||
$this->forge->addPrimaryKey('id');
|
||||
|
||||
$this->forge->createTable("chat_departments", true);
|
||||
}
|
||||
|
||||
public function down()
|
||||
|
||||
@ -11,7 +11,7 @@ class ChatsTable extends Migration
|
||||
"id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
"autoincrement" => true
|
||||
"auto_increment" => true
|
||||
],
|
||||
"chat_department_id" => [
|
||||
"type" => "INT",
|
||||
@ -23,14 +23,14 @@ class ChatsTable extends Migration
|
||||
"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->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([
|
||||
@ -40,24 +40,23 @@ class ChatsTable extends Migration
|
||||
],
|
||||
"updated_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"nullable" => true,
|
||||
"null" => true,
|
||||
],
|
||||
"deleted_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"nullable" => true,
|
||||
"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);
|
||||
|
||||
$this->forge->addForeignKey('chat_department_id', 'chat_departments', 'id');
|
||||
$this->forge->createTable("chats", true);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
$this->forge->dropTable("chats",true);
|
||||
$this->forge->dropTable("chats", true);
|
||||
}
|
||||
}
|
||||
@ -10,7 +10,7 @@ class ChatMessages extends Migration
|
||||
protected array $COLUMNS = [
|
||||
"id" => [
|
||||
"type" => "INT",
|
||||
"autoincrement" => true,
|
||||
"auto_increment" => true,
|
||||
],
|
||||
"chat_id" => [
|
||||
"type" => "INT",
|
||||
@ -20,7 +20,7 @@ class ChatMessages extends Migration
|
||||
"user_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
|
||||
|
||||
],
|
||||
"message" => [
|
||||
"type" => "TEXT",
|
||||
@ -31,32 +31,33 @@ class ChatMessages extends Migration
|
||||
public function up()
|
||||
{
|
||||
$this->forge->addField($this->COLUMNS);
|
||||
$this->forge->addForeignKey(['user_id'], 'users', ['id']);
|
||||
$this->forge->addForeignKey(['chat_id'], 'chats', ['id']);
|
||||
|
||||
$currenttime = new RawSql("CURRENT_TIMESTAMP");
|
||||
$this->forge->addField([
|
||||
"created_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"default" => $currenttime,
|
||||
|
||||
|
||||
],
|
||||
"updated_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"nullable" => true,
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
"deleted_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"nullable" => true,
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
]);
|
||||
$this->forge->createTable("chat_messages",true);
|
||||
|
||||
$this->forge->addPrimaryKey('id');
|
||||
$this->forge->addForeignKey(['user_id'], 'users', ['id']);
|
||||
$this->forge->addForeignKey(['chat_id'], 'chats', ['id']);
|
||||
$this->forge->createTable("chat_messages", true);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropTable("chat_messages",true);
|
||||
$this->forge->dropTable("chat_messages", true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,8 +8,9 @@ use CodeIgniter\Database\RawSql;
|
||||
class ChatDepartmentUsers extends Migration
|
||||
{
|
||||
protected array $COLUMNS = [
|
||||
"chat_deparment_id" => [
|
||||
"chat_department_id" => [
|
||||
"type" => "INT",
|
||||
"unsigned" => true,
|
||||
],
|
||||
"user_id" => [
|
||||
"type" => "INT",
|
||||
@ -19,34 +20,31 @@ class ChatDepartmentUsers extends Migration
|
||||
public function up()
|
||||
{
|
||||
$this->forge->addField($this->COLUMNS);
|
||||
$this->forge->addForeignKey(["user_id"],"users",["id"]);
|
||||
$currenttime = new RawSql("CURRENT_TIMESTAMP");
|
||||
$this->forge->addField([
|
||||
"created_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"default" => $currenttime,
|
||||
|
||||
|
||||
],
|
||||
"updated_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"nullable" => true,
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
"deleted_at" => [
|
||||
"type" => "TIMESTAMP",
|
||||
"nullable" => true,
|
||||
"null" => true,
|
||||
|
||||
],
|
||||
]);
|
||||
$this->forge->createTable("chat_department_users",true);
|
||||
|
||||
|
||||
|
||||
$this->forge->addForeignKey(["user_id"], "users", ["id"]);
|
||||
$this->forge->addForeignKey(["chat_department_id"], "chat_departments", ["id"]);
|
||||
$this->forge->createTable("chat_department_users", true);
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropTable("chat_department_users");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user