forge->addField([ 'id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true], 'name' => ['type' => 'VARCHAR', 'constraint' => 100], // only a salted hash is stored; the plaintext token is shown once at creation 'key_hash' => ['type' => 'VARCHAR', 'constraint' => 64], 'key_prefix' => ['type' => 'VARCHAR', 'constraint' => 12], 'rate_limit_per_hour' => ['type' => 'INT', 'unsigned' => true, 'default' => 120], 'request_count' => ['type' => 'BIGINT', 'unsigned' => true, 'default' => 0], 'is_active' => ['type' => 'TINYINT', 'constraint' => 1, 'default' => 1], 'last_used_at' => ['type' => 'DATETIME', 'null' => true], 'created_at' => ['type' => 'DATETIME', 'null' => true], ]); $this->forge->addPrimaryKey('id'); $this->forge->addUniqueKey('key_hash'); $this->forge->createTable('api_keys', true); $this->forge->addField([ 'key' => ['type' => 'VARCHAR', 'constraint' => 100, 'unique' => true], 'value' => ['type' => 'TEXT'], 'updated_at' => ['type' => 'DATETIME', 'null' => true], ]); $this->forge->createTable('settings', true); } public function down(): void { $this->forge->dropTable('api_keys', true); $this->forge->dropTable('settings', true); } }