diff --git a/server-v2/database/migrations/1631392754960_matches.ts b/server-v2/database/migrations/1631392754960_matches.ts index 4651f81..e5c0e6e 100644 --- a/server-v2/database/migrations/1631392754960_matches.ts +++ b/server-v2/database/migrations/1631392754960_matches.ts @@ -8,14 +8,16 @@ export default class Matches extends BaseSchema { table.string('id', 15).primary() table.bigInteger('game_id').notNullable() table.specificType('map', 'smallint').notNullable() - table.specificType('gamemode', 'smallint').notNullable() + table.specificType('gamemode', 'smallint').notNullable().index() table.bigInteger('date').notNullable() table.string('region', 4).notNullable() table.specificType('result', 'smallint').notNullable() - table.float('season').notNullable() + table.float('season').notNullable().index() table.specificType('game_duration', 'smallint').unsigned().notNullable() }) + + // this.schema.alterTable } public async down() { diff --git a/server-v2/database/migrations/1631392766690_match_players.ts b/server-v2/database/migrations/1631392766690_match_players.ts index 499ae52..9e37ff5 100644 --- a/server-v2/database/migrations/1631392766690_match_players.ts +++ b/server-v2/database/migrations/1631392766690_match_players.ts @@ -6,19 +6,19 @@ export default class MatchPlayers extends BaseSchema { public async up() { this.schema.createTable(this.tableName, (table) => { table.increments('id') - table.string('match_id', 15).notNullable() + table.string('match_id', 15).notNullable().index() table.specificType('participant_id', 'smallint').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.specificType('win', 'smallint').notNullable() table.specificType('loss', 'smallint').notNullable() table.specificType('remake', 'smallint').notNullable() - table.specificType('team', 'smallint').notNullable() - table.specificType('team_position', 'smallint').notNullable() + table.specificType('team', 'smallint').notNullable().index() + table.specificType('team_position', 'smallint').notNullable().index() table.specificType('kills', 'smallint').unsigned().notNullable() table.specificType('deaths', 'smallint').unsigned().notNullable() @@ -27,7 +27,7 @@ export default class MatchPlayers extends BaseSchema { table.float('kp').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('double_kills', 'smallint').notNullable() @@ -66,6 +66,10 @@ export default class MatchPlayers extends BaseSchema { table.integer('perks_secondary_style').notNullable() table.specificType('perks_selected', 'INT[]').notNullable() }) + + this.schema.alterTable(this.tableName, (table) => { + table.unique(['match_id', 'summoner_puuid']) + }) } public async down() { diff --git a/server-v2/database/migrations/1631392778620_summoner_names.ts b/server-v2/database/migrations/1631392778620_summoner_names.ts index fca2f30..c2af3f2 100644 --- a/server-v2/database/migrations/1631392778620_summoner_names.ts +++ b/server-v2/database/migrations/1631392778620_summoner_names.ts @@ -6,14 +6,18 @@ export default class SummonerNames extends BaseSchema { public async up() { this.schema.createTable(this.tableName, (table) => { table.increments('id') - table.string('summoner_puuid', 78).notNullable() - table.string('name', 16).notNullable() + table.string('summoner_puuid', 78).notNullable().index() + table.string('name', 16).notNullable().index() /** * Uses timestamptz for PostgreSQL and DATETIME2 for MSSQL */ table.timestamp('created_at', { useTz: true }) }) + + this.schema.alterTable(this.tableName, (table) => { + table.unique(['summoner_puuid', 'name']) + }) } public async down() { diff --git a/server-v2/database/migrations/1631392817716_summoner_matchlist.ts b/server-v2/database/migrations/1631392817716_summoner_matchlist.ts index da4680c..e4f5929 100644 --- a/server-v2/database/migrations/1631392817716_summoner_matchlist.ts +++ b/server-v2/database/migrations/1631392817716_summoner_matchlist.ts @@ -6,8 +6,12 @@ export default class SummonerMatchLists extends BaseSchema { public async up() { this.schema.createTable(this.tableName, (table) => { table.increments('id') - table.string('summoner_puuid', 78).notNullable() - table.string('match_id', 15).notNullable() + table.string('summoner_puuid', 78).notNullable().index() + table.string('match_id', 15).notNullable().index() + }) + + this.schema.alterTable(this.tableName, (table) => { + table.unique(['summoner_puuid', 'match_id']) }) } diff --git a/server-v2/database/migrations/1631397498477_match_teams.ts b/server-v2/database/migrations/1631397498477_match_teams.ts index 2264819..1183a29 100644 --- a/server-v2/database/migrations/1631397498477_match_teams.ts +++ b/server-v2/database/migrations/1631397498477_match_teams.ts @@ -6,9 +6,9 @@ export default class MatchTeams extends BaseSchema { public async up() { this.schema.createTable(this.tableName, (table) => { 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.specificType('barons', 'smallint').notNullable() diff --git a/server-v2/database/migrations/1631807093726_match_player_ranks.ts b/server-v2/database/migrations/1631807093726_match_player_ranks.ts index 715e60f..44563b3 100644 --- a/server-v2/database/migrations/1631807093726_match_player_ranks.ts +++ b/server-v2/database/migrations/1631807093726_match_player_ranks.ts @@ -7,7 +7,7 @@ export default class MatchPlayerRanks extends BaseSchema { this.schema.createTable(this.tableName, (table) => { table.increments('id') - table.integer('player_id').unsigned().notNullable() + table.integer('player_id').unsigned().notNullable().index() table.specificType('gamemode', 'smallint').notNullable()