Archived
1
This repository has been archived on 2022-11-04. You can view files and clone it, but cannot push or open issues or pull requests.
i2_bot/lib/migrations/36_create_tournament_reports.go

40 lines
1.4 KiB
Go
Raw Permalink Normal View History

// i2_bot Instinct PokememBro Bot
// Copyright (c) 2017-2018 Vladimir "fat0troll" Hodakov
package migrations
import (
"database/sql"
)
// CreateTournamentReportsUp creates `tournament_reports` table
func CreateTournamentReportsUp(tx *sql.Tx) error {
request := "CREATE TABLE `tournament_reports` ("
request += "`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID рапорта',"
request += "`player_id` int(11) NOT NULL COMMENT 'Игрок, который сходил на турнир',"
request += "`tournament_number` int(11) NOT NULL COMMENT 'Номер турнира в игре',"
request += "`target` varchar(191) NOT NULL COMMENT 'Цель атаки',"
request += "`created_at` datetime NOT NULL COMMENT 'Добавлен в базу',"
request += "PRIMARY KEY (`id`),"
request += "UNIQUE KEY `id` (`id`),"
request += "KEY `tournament_reports_player_id` (`player_id`),"
request += "KEY `tournament_repots_tournament_number` (`tournament_number`)"
request += ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='Репорты результата Турнира лиг'"
_, err := tx.Exec(request)
if err != nil {
return err
}
return nil
}
// CreateTournamentReportsDown drops `tournament_reports` table
func CreateTournamentReportsDown(tx *sql.Tx) error {
_, err := tx.Exec("DROP TABLE `tournament_reports`")
if err != nil {
return err
}
return nil
}