aboutsummaryrefslogtreecommitdiffstats
path: root/database/migrations/1696110557648_jwt_tokens.ts
diff options
context:
space:
mode:
Diffstat (limited to 'database/migrations/1696110557648_jwt_tokens.ts')
-rw-r--r--database/migrations/1696110557648_jwt_tokens.ts29
1 files changed, 29 insertions, 0 deletions
diff --git a/database/migrations/1696110557648_jwt_tokens.ts b/database/migrations/1696110557648_jwt_tokens.ts
new file mode 100644
index 0000000..9400de7
--- /dev/null
+++ b/database/migrations/1696110557648_jwt_tokens.ts
@@ -0,0 +1,29 @@
1import BaseSchema from '@ioc:Adonis/Lucid/Schema';
2
3export default class JwtTokens extends BaseSchema {
4 protected tableName = 'jwt_tokens';
5
6 public async up() {
7 this.schema.createTable(this.tableName, table => {
8 table.increments('id').primary();
9 table
10 .integer('user_id')
11 .unsigned()
12 .references('users.id')
13 .onDelete('CASCADE');
14 table.string('name').notNullable();
15 table.string('type').notNullable();
16 table.string('token', 64).notNullable().unique();
17 table.timestamp('expires_at', { useTz: true }).nullable();
18 table.string('refresh_token').notNullable().unique().index();
19 table
20 .timestamp('refresh_token_expires_at', { useTz: true })
21 .notNullable();
22 table.timestamp('created_at', { useTz: true }).notNullable();
23 });
24 }
25
26 public async down() {
27 this.schema.dropTable(this.tableName);
28 }
29}