Files
safekat/ci4/app/Database/Migrations/2025-02-22-080100_WikiContentsMigration.php
2025-02-25 18:41:59 +01:00

84 lines
2.1 KiB
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
use CodeIgniter\Database\RawSql;
class WikiContentsMigration extends Migration
{
protected array $COLUMNS = [
'id' => [
'type' => 'INT',
'unsigned' => true,
'auto_increment' => true,
],
'locale' => [
'type' => 'VARCHAR',
'constraint' => 255,
'default' => 'es',
],
'page_id' => [
'type' => 'INT',
'unsigned' => true,
],
'editor_data' => [
'type' => 'LONGTEXT',
'null' => true,
],
'published_data' => [
'type' => 'LONGTEXT',
'null' => true,
],
'published_by' => [
'type' => 'INT',
'unsigned' => true,
'null' => true,
'constraint' => 10,
],
'last_edit_by' => [
'type' => 'INT',
'unsigned' => true,
'null' => true,
'constraint' => 10,
],
];
public function up()
{
$this->forge->addField($this->COLUMNS);
$currenttime = new RawSql('CURRENT_TIMESTAMP');
$this->forge->addField([
'published_at' => [
'type' => 'TIMESTAMP',
'null' => true,
],
'created_at' => [
'type' => 'TIMESTAMP',
'default' => $currenttime,
],
'updated_at' => [
'type' => 'TIMESTAMP',
'null' => true,
],
'deleted_at' => [
'type' => 'TIMESTAMP',
'null' => true,
],
]);
$this->forge->addPrimaryKey('id');
$this->forge->addForeignKey('page_id','wiki_pages','id');
$this->forge->addForeignKey('published_by','users','id');
$this->forge->addForeignKey('last_edit_by','users','id');
$this->forge->createTable("wiki_contents");
}
public function down()
{
$this->forge->dropTable("wiki_contents");
}
}