aboutsummaryrefslogtreecommitdiffstats
path: root/database/migrations/1503250034280_token.ts
blob: 3830c98bc91d338c855b5945ea8f82d6cd232701 (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)
  }
}