LeagueStats/server-v2/database/migrations/1631392778620_summoner_names.ts

27 lines
707 B
TypeScript
Raw Normal View History

2021-09-12 13:16:08 +00:00
import BaseSchema from '@ioc:Adonis/Lucid/Schema'
export default class SummonerNames extends BaseSchema {
protected tableName = 'summoner_names'
public async up() {
this.schema.createTable(this.tableName, (table) => {
table.increments('id')
2021-09-19 15:47:07 +00:00
table.string('summoner_puuid', 78).notNullable().index()
table.string('name', 16).notNullable().index()
2021-09-12 13:16:08 +00:00
/**
* Uses timestamptz for PostgreSQL and DATETIME2 for MSSQL
*/
table.timestamp('created_at', { useTz: true })
})
2021-09-19 15:47:07 +00:00
this.schema.alterTable(this.tableName, (table) => {
table.unique(['summoner_puuid', 'name'])
})
2021-09-12 13:16:08 +00:00
}
public async down() {
this.schema.dropTable(this.tableName)
}
}