feat: add timestamp fields

This commit is contained in:
amazuecos
2024-09-17 23:36:10 +02:00
parent 51dc0ca676
commit db3f79da29
4 changed files with 81 additions and 3 deletions

View File

@ -3,6 +3,7 @@
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use CodeIgniter\Database\RawSql;
class ChatDepartmentUsers extends Migration
{
@ -12,13 +13,32 @@ class ChatDepartmentUsers extends Migration
],
"user_id" => [
"type" => "INT",
"unsigned" => true,
],
];
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,
],
"deleted_at" => [
"type" => "TIMESTAMP",
"nullable" => true,
],
]);
$this->forge->createTable("chat_department_users");
$this->forge->addForeignKey("user_id","users","id");