mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
feat: add timestamp fields
This commit is contained in:
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
|
use CodeIgniter\Database\RawSql;
|
||||||
use CodeIgniter\Database\Migration;
|
use CodeIgniter\Database\Migration;
|
||||||
|
|
||||||
|
|
||||||
class ChatsTable extends Migration
|
class ChatsTable extends Migration
|
||||||
{
|
{
|
||||||
protected array $COLUMNS = [
|
protected array $COLUMNS = [
|
||||||
@ -21,7 +21,9 @@ class ChatsTable extends Migration
|
|||||||
"type" => "INT",
|
"type" => "INT",
|
||||||
"constraint" => 16,
|
"constraint" => 16,
|
||||||
"unsigned" => true,
|
"unsigned" => true,
|
||||||
]
|
],
|
||||||
|
|
||||||
|
|
||||||
];
|
];
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
@ -30,6 +32,22 @@ class ChatsTable extends Migration
|
|||||||
$this->forge->dropTable("chat_participantes",true);
|
$this->forge->dropTable("chat_participantes",true);
|
||||||
|
|
||||||
$this->forge->addField($this->COLUMNS);
|
$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->addPrimaryKey('id');
|
||||||
$this->forge->addForeignKey('pedido_id', 'pedidos', 'id');
|
$this->forge->addForeignKey('pedido_id', 'pedidos', 'id');
|
||||||
$this->forge->createTable("chats");
|
$this->forge->createTable("chats");
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
use CodeIgniter\Database\Migration;
|
||||||
|
use CodeIgniter\Database\RawSql;
|
||||||
|
|
||||||
class ChatDepartments extends Migration
|
class ChatDepartments extends Migration
|
||||||
{
|
{
|
||||||
@ -17,10 +18,29 @@ class ChatDepartments extends Migration
|
|||||||
"constraint" => '45',
|
"constraint" => '45',
|
||||||
"unique" => true,
|
"unique" => true,
|
||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$this->forge->addField($this->COLUMNS);
|
$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->createTable("chat_departments");
|
$this->forge->createTable("chat_departments");
|
||||||
$this->forge->addPrimaryKey('id');
|
$this->forge->addPrimaryKey('id');
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
use CodeIgniter\Database\Migration;
|
||||||
|
use CodeIgniter\Database\RawSql;
|
||||||
|
|
||||||
class ChatMessages extends Migration
|
class ChatMessages extends Migration
|
||||||
{
|
{
|
||||||
@ -19,15 +20,34 @@ class ChatMessages extends Migration
|
|||||||
"user_id" => [
|
"user_id" => [
|
||||||
"type" => "INT",
|
"type" => "INT",
|
||||||
"unsigned" => true,
|
"unsigned" => true,
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
||||||
];
|
];
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$this->forge->addField($this->COLUMNS);
|
$this->forge->addField($this->COLUMNS);
|
||||||
$this->forge->addForeignKey(['user_id'], 'users', ['id']);
|
$this->forge->addForeignKey(['user_id'], 'users', ['id']);
|
||||||
$this->forge->addForeignKey(['chat_id'], 'chats', ['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,
|
||||||
|
|
||||||
|
],
|
||||||
|
"deleted_at" => [
|
||||||
|
"type" => "TIMESTAMP",
|
||||||
|
"nullable" => true,
|
||||||
|
|
||||||
|
],
|
||||||
|
]);
|
||||||
$this->forge->createTable("chat_messages");
|
$this->forge->createTable("chat_messages");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
namespace App\Database\Migrations;
|
namespace App\Database\Migrations;
|
||||||
|
|
||||||
use CodeIgniter\Database\Migration;
|
use CodeIgniter\Database\Migration;
|
||||||
|
use CodeIgniter\Database\RawSql;
|
||||||
|
|
||||||
class ChatDepartmentUsers extends Migration
|
class ChatDepartmentUsers extends Migration
|
||||||
{
|
{
|
||||||
@ -12,13 +13,32 @@ class ChatDepartmentUsers extends Migration
|
|||||||
],
|
],
|
||||||
"user_id" => [
|
"user_id" => [
|
||||||
"type" => "INT",
|
"type" => "INT",
|
||||||
|
"unsigned" => true,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$this->forge->addField($this->COLUMNS);
|
$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,
|
||||||
|
|
||||||
|
],
|
||||||
|
"deleted_at" => [
|
||||||
|
"type" => "TIMESTAMP",
|
||||||
|
"nullable" => true,
|
||||||
|
|
||||||
|
],
|
||||||
|
]);
|
||||||
$this->forge->createTable("chat_department_users");
|
$this->forge->createTable("chat_department_users");
|
||||||
$this->forge->addForeignKey("user_id","users","id");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user