29 lines
569 B
JavaScript
29 lines
569 B
JavaScript
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');
|
|
};
|