aboutsummaryrefslogtreecommitdiffstats
path: root/database/migrations/1503250034280_token.ts
blob: f7b572be7e92ca0aa83781807162bd2ccb550d0f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { BaseSchema } from '@adonisjs/lucid/schema';

export default class extends BaseSchema {
  protected tableName = 'tokens';

  public async up(): Promise<void> {
    this.schema.createTable(this.tableName, table => {
      table.increments();
      table.integer('user_id').unsigned().references('users.id');
      table.string('token', 255).notNullable().unique().index();
      table.string('type', 80).notNullable();
      table.boolean('is_revoked').defaultTo(false);
      table.timestamps();
    });
  }

  public async down(): Promise<void> {
    this.schema.dropTable(this.tableName);
  }
}