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

@ -2,9 +2,9 @@
namespace App\Database\Migrations;
use CodeIgniter\Database\RawSql;
use CodeIgniter\Database\Migration;
class ChatsTable extends Migration
{
protected array $COLUMNS = [
@ -21,7 +21,9 @@ class ChatsTable extends Migration
"type" => "INT",
"constraint" => 16,
"unsigned" => true,
]
],
];
public function up()
{
@ -30,6 +32,22 @@ class ChatsTable extends Migration
$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",
"nullable" => true,
],
"deleted_at" => [
"type" => "TIMESTAMP",
"nullable" => true,
],
]);
$this->forge->addPrimaryKey('id');
$this->forge->addForeignKey('pedido_id', 'pedidos', 'id');
$this->forge->createTable("chats");