mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
feat: add some index on table schemas
This commit is contained in:
parent
4fb60cc02a
commit
1e2cc8e898
6 changed files with 28 additions and 14 deletions
|
|
@ -8,14 +8,16 @@ export default class Matches extends BaseSchema {
|
||||||
table.string('id', 15).primary()
|
table.string('id', 15).primary()
|
||||||
table.bigInteger('game_id').notNullable()
|
table.bigInteger('game_id').notNullable()
|
||||||
table.specificType('map', 'smallint').notNullable()
|
table.specificType('map', 'smallint').notNullable()
|
||||||
table.specificType('gamemode', 'smallint').notNullable()
|
table.specificType('gamemode', 'smallint').notNullable().index()
|
||||||
table.bigInteger('date').notNullable()
|
table.bigInteger('date').notNullable()
|
||||||
table.string('region', 4).notNullable()
|
table.string('region', 4).notNullable()
|
||||||
table.specificType('result', 'smallint').notNullable()
|
table.specificType('result', 'smallint').notNullable()
|
||||||
|
|
||||||
table.float('season').notNullable()
|
table.float('season').notNullable().index()
|
||||||
table.specificType('game_duration', 'smallint').unsigned().notNullable()
|
table.specificType('game_duration', 'smallint').unsigned().notNullable()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// this.schema.alterTable
|
||||||
}
|
}
|
||||||
|
|
||||||
public async down() {
|
public async down() {
|
||||||
|
|
|
||||||
|
|
@ -6,19 +6,19 @@ export default class MatchPlayers extends BaseSchema {
|
||||||
public async up() {
|
public async up() {
|
||||||
this.schema.createTable(this.tableName, (table) => {
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
table.increments('id')
|
table.increments('id')
|
||||||
table.string('match_id', 15).notNullable()
|
table.string('match_id', 15).notNullable().index()
|
||||||
|
|
||||||
table.specificType('participant_id', 'smallint').notNullable()
|
table.specificType('participant_id', 'smallint').notNullable()
|
||||||
table.string('summoner_id', 63).notNullable()
|
table.string('summoner_id', 63).notNullable()
|
||||||
table.string('summoner_puuid', 78).notNullable()
|
table.string('summoner_puuid', 78).notNullable().index()
|
||||||
table.string('summoner_name', 16).notNullable()
|
table.string('summoner_name', 16).notNullable()
|
||||||
|
|
||||||
table.specificType('win', 'smallint').notNullable()
|
table.specificType('win', 'smallint').notNullable()
|
||||||
table.specificType('loss', 'smallint').notNullable()
|
table.specificType('loss', 'smallint').notNullable()
|
||||||
table.specificType('remake', 'smallint').notNullable()
|
table.specificType('remake', 'smallint').notNullable()
|
||||||
|
|
||||||
table.specificType('team', 'smallint').notNullable()
|
table.specificType('team', 'smallint').notNullable().index()
|
||||||
table.specificType('team_position', 'smallint').notNullable()
|
table.specificType('team_position', 'smallint').notNullable().index()
|
||||||
|
|
||||||
table.specificType('kills', 'smallint').unsigned().notNullable()
|
table.specificType('kills', 'smallint').unsigned().notNullable()
|
||||||
table.specificType('deaths', 'smallint').unsigned().notNullable()
|
table.specificType('deaths', 'smallint').unsigned().notNullable()
|
||||||
|
|
@ -27,7 +27,7 @@ export default class MatchPlayers extends BaseSchema {
|
||||||
table.float('kp').notNullable()
|
table.float('kp').notNullable()
|
||||||
|
|
||||||
table.specificType('champ_level', 'smallint').notNullable()
|
table.specificType('champ_level', 'smallint').notNullable()
|
||||||
table.specificType('champion_id', 'smallint').notNullable()
|
table.specificType('champion_id', 'smallint').notNullable().index()
|
||||||
table.specificType('champion_role', 'smallint').notNullable()
|
table.specificType('champion_role', 'smallint').notNullable()
|
||||||
|
|
||||||
table.specificType('double_kills', 'smallint').notNullable()
|
table.specificType('double_kills', 'smallint').notNullable()
|
||||||
|
|
@ -66,6 +66,10 @@ export default class MatchPlayers extends BaseSchema {
|
||||||
table.integer('perks_secondary_style').notNullable()
|
table.integer('perks_secondary_style').notNullable()
|
||||||
table.specificType('perks_selected', 'INT[]').notNullable()
|
table.specificType('perks_selected', 'INT[]').notNullable()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.schema.alterTable(this.tableName, (table) => {
|
||||||
|
table.unique(['match_id', 'summoner_puuid'])
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async down() {
|
public async down() {
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,18 @@ export default class SummonerNames extends BaseSchema {
|
||||||
public async up() {
|
public async up() {
|
||||||
this.schema.createTable(this.tableName, (table) => {
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
table.increments('id')
|
table.increments('id')
|
||||||
table.string('summoner_puuid', 78).notNullable()
|
table.string('summoner_puuid', 78).notNullable().index()
|
||||||
table.string('name', 16).notNullable()
|
table.string('name', 16).notNullable().index()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses timestamptz for PostgreSQL and DATETIME2 for MSSQL
|
* Uses timestamptz for PostgreSQL and DATETIME2 for MSSQL
|
||||||
*/
|
*/
|
||||||
table.timestamp('created_at', { useTz: true })
|
table.timestamp('created_at', { useTz: true })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.schema.alterTable(this.tableName, (table) => {
|
||||||
|
table.unique(['summoner_puuid', 'name'])
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
public async down() {
|
public async down() {
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,12 @@ export default class SummonerMatchLists extends BaseSchema {
|
||||||
public async up() {
|
public async up() {
|
||||||
this.schema.createTable(this.tableName, (table) => {
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
table.increments('id')
|
table.increments('id')
|
||||||
table.string('summoner_puuid', 78).notNullable()
|
table.string('summoner_puuid', 78).notNullable().index()
|
||||||
table.string('match_id', 15).notNullable()
|
table.string('match_id', 15).notNullable().index()
|
||||||
|
})
|
||||||
|
|
||||||
|
this.schema.alterTable(this.tableName, (table) => {
|
||||||
|
table.unique(['summoner_puuid', 'match_id'])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@ export default class MatchTeams extends BaseSchema {
|
||||||
public async up() {
|
public async up() {
|
||||||
this.schema.createTable(this.tableName, (table) => {
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
table.increments('id')
|
table.increments('id')
|
||||||
table.string('match_id', 15)
|
table.string('match_id', 15).index()
|
||||||
|
|
||||||
table.specificType('color', 'smallint').notNullable() // 100 ou 200
|
table.specificType('color', 'smallint').notNullable().index() // 100 ou 200
|
||||||
table.string('result', 6) // Win - Remake - Fail
|
table.string('result', 6) // Win - Remake - Fail
|
||||||
|
|
||||||
table.specificType('barons', 'smallint').notNullable()
|
table.specificType('barons', 'smallint').notNullable()
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ export default class MatchPlayerRanks extends BaseSchema {
|
||||||
this.schema.createTable(this.tableName, (table) => {
|
this.schema.createTable(this.tableName, (table) => {
|
||||||
table.increments('id')
|
table.increments('id')
|
||||||
|
|
||||||
table.integer('player_id').unsigned().notNullable()
|
table.integer('player_id').unsigned().notNullable().index()
|
||||||
|
|
||||||
table.specificType('gamemode', 'smallint').notNullable()
|
table.specificType('gamemode', 'smallint').notNullable()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue