mirror of
https://github.com/JGH0/Todo-App-Backend.git
synced 2026-06-03 13:28:47 +02:00
added migration seeders models and test script
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class CreateUserThemesTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->forge->addField([
|
||||
'id' => [
|
||||
'type' => 'CHAR',
|
||||
'constraint' => 36,
|
||||
'null' => false,
|
||||
],
|
||||
'user_id' => [
|
||||
'type' => 'CHAR',
|
||||
'constraint' => 36,
|
||||
'null' => false,
|
||||
],
|
||||
'theme_id' => [
|
||||
'type' => 'CHAR',
|
||||
'constraint' => 36,
|
||||
'null' => false,
|
||||
],
|
||||
'installed_at' => [
|
||||
'type' => 'DATETIME',
|
||||
'null' => true,
|
||||
],
|
||||
'active' => [
|
||||
'type' => 'BOOLEAN',
|
||||
'default' => false,
|
||||
'comment' => 'Whether this is the user\'s currently active theme',
|
||||
],
|
||||
'custom_settings' => [
|
||||
'type' => 'JSON',
|
||||
'null' => true,
|
||||
'default' => '{}',
|
||||
'comment' => 'User overrides for theme variables',
|
||||
],
|
||||
]);
|
||||
$this->forge->addKey('id', true);
|
||||
$this->forge->addUniqueKey(['user_id', 'theme_id']);
|
||||
$this->forge->addForeignKey('user_id', 'users', 'id', 'CASCADE', 'CASCADE');
|
||||
$this->forge->addForeignKey('theme_id', 'marketplace_themes', 'id', 'CASCADE', 'CASCADE');
|
||||
$this->forge->createTable('user_themes');
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
$this->forge->dropTable('user_themes');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user