database/migrations/1680871718619_api_tokens.ts   A
last analyzed

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 26
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 18
mnd 0
bc 0
fnc 2
dl 0
loc 26
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
rs 10

2 Functions

Rating   Name   Duplication   Size   Complexity  
A 1680871718619_api_tokens.ts ➔ down 0 3 1
A 1680871718619_api_tokens.ts ➔ up 0 14 1
1
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
2
3
export default class extends BaseSchema {
4
  protected tableName = 'api_tokens'
5
6
  public async up() {
7
    this.schema.createTable(this.tableName, (table) => {
8
      table.increments('id').primary()
9
      table.integer('user_id').unsigned().references('id').inTable('users').onDelete('CASCADE')
10
      table.string('name').notNullable()
11
      table.string('type').notNullable()
12
      table.string('token', 64).notNullable().unique()
13
14
      /**
15
       * Uses timestampz for PostgreSQL and DATETIME2 for MSSQL
16
       */
17
      table.timestamp('expires_at', { useTz: true }).nullable()
18
      table.timestamp('created_at', { useTz: true }).notNullable()
19
    })
20
  }
21
22
  public async down() {
23
    this.schema.dropTable(this.tableName)
24
  }
25
}
26