Skip to content

Commit

Permalink
Update 2021-10-21-103415_create_rest_server_tables.php
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordi committed Feb 9, 2022
1 parent 2f0a31c commit 57c8394
Showing 1 changed file with 18 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,46 +34,44 @@ public function up()
$this->forge->createTable($config->configRestPetitionsTable, true);

/*
* Users
* Keys
*/
$this->forge->addField([
'id' => ['type' => 'int', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
'name' => ['type' => 'varchar', 'constraint' => 255, 'null' => false],
'id' => ['type' => 'int', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
$config->restKeyColumn => ['type' => 'varchar', 'constraint' => $config->restKeyLength, 'null' => false],
'level' => ['type' => 'int', 'constraint' => 2, 'null' => false],
'ignore_limits' => ['type' => 'tinyint', 'constraint' => 1, 'null' => false, 'default' => 0],
'is_private_key' => ['type' => 'tinyint', 'constraint' => 1, 'null' => false, 'default' => 0],
'ip_addresses' => ['type' => 'text', 'null' => null, 'default' => null],
'created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
'deleted_at' => ['type' => 'datetime', 'null' => true, 'default' => null]
]);

$this->forge->addKey('id', true);
$this->forge->addKey('deleted_at');
$this->forge->addUniqueKey('name');
$this->forge->addUniqueKey('key');

$this->forge->createTable($config->restUsersTable, true);
$this->forge->createTable($config->restKeysTable, true);

/*
* Keys
* Users
*/
$this->forge->addField([
'id' => ['type' => 'int', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
'user_id' => ['type' => 'int', 'unsigned' => true, 'constraint' => 11, 'null' => false],
$config->restKeyColumn => ['type' => 'varchar', 'constraint' => $config->restKeyLength, 'null' => false],
'level' => ['type' => 'int', 'constraint' => 2, 'null' => false],
'ignore_limits' => ['type' => 'tinyint', 'constraint' => 1, 'null' => false, 'default' => 0],
'is_private_key' => ['type' => 'tinyint', 'constraint' => 1, 'null' => false, 'default' => 0],
'ip_addresses' => ['type' => 'text', 'null' => null, 'default' => null],
'id' => ['type' => 'int', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
'name' => ['type' => 'varchar', 'constraint' => 255, 'null' => false],
$config->userKeyColumn => ['type' => 'int', 'constraint' => 11, 'unsigned' => true, 'null' => true],
'created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
'updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
'deleted_at' => ['type' => 'datetime', 'null' => true, 'default' => null]
]);

$this->forge->addKey('id', true);
$this->forge->addKey('user_id');
$this->forge->addUniqueKey('key');
$this->forge->addUniqueKey(['user_id','key']);
$this->forge->addForeignKey('user_id', $config->restUsersTable, 'id', '', 'CASCADE');

$this->forge->createTable($config->restKeysTable, true);
$this->forge->addKey('deleted_at');
$this->forge->addUniqueKey('name');
$this->forge->addForeignKey( $config->userKeyColumn, $config->restKeysTable, 'id', '', 'CASCADE');

$this->forge->createTable($config->restUsersTable, true);

/*
* Logs
*/
Expand Down

0 comments on commit 57c8394

Please # to comment.