Added API keys table.

This commit is contained in:
DebaucheryLibrarian 2024-08-31 05:01:15 +02:00
parent efcbe2b1a1
commit 9e7d46f081
1 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,28 @@
exports.up = async (knex) => {
await knex.schema.createTable('users_keys', (table) => {
table.increments('id');
table.integer('user_id')
.notNullable()
.references('id')
.inTable('users');
table.text('key')
.notNullable();
table.string('identifier');
table.unique(['user_id', 'identifier']);
table.datetime('last_used_at');
table.specificType('last_used_ip', 'inet');
table.datetime('created_at')
.notNullable()
.defaultTo(knex.fn.now());
});
};
exports.down = async (knex) => {
await knex.schema.dropTable('users_keys');
};