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:
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user