2017-10-06 02:56:06 +04:00
|
|
|
|
// i2_bot – Instinct PokememBro Bot
|
2018-03-31 16:45:09 +04:00
|
|
|
|
// Copyright (c) 2017-2018 Vladimir "fat0troll" Hodakov
|
2017-10-06 02:56:06 +04:00
|
|
|
|
|
|
|
|
|
package migrations
|
|
|
|
|
|
|
|
|
|
import (
|
2017-10-18 07:03:34 +04:00
|
|
|
|
"database/sql"
|
2017-10-06 02:56:06 +04:00
|
|
|
|
)
|
|
|
|
|
|
2017-11-14 03:44:21 +04:00
|
|
|
|
// CreateProfilesUp creates `profiles` table
|
2017-10-06 02:56:06 +04:00
|
|
|
|
func CreateProfilesUp(tx *sql.Tx) error {
|
2017-11-14 03:44:21 +04:00
|
|
|
|
request := "CREATE TABLE `profiles` ("
|
|
|
|
|
request += "`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID сохраненного профиля',"
|
|
|
|
|
request += "`player_id` int(11) NOT NULL COMMENT 'ID игрока в системе',"
|
|
|
|
|
request += "`nickname` varchar(191) NOT NULL COMMENT 'Ник игрока',"
|
|
|
|
|
request += "`telegram_nickname` varchar(191) NOT NULL COMMENT 'Ник в Телеграме (@)',"
|
|
|
|
|
request += "`level_id` int(11) NOT NULL COMMENT 'Уровень',"
|
|
|
|
|
request += "`exp` int(11) NOT NULL COMMENT 'Опыт',"
|
|
|
|
|
request += "`egg_exp` int(11) NOT NULL COMMENT 'Опыт яйца',"
|
|
|
|
|
request += "`power` int(11) NOT NULL COMMENT 'Сила без оружия',"
|
|
|
|
|
request += "`weapon_id` int(11) NOT NULL COMMENT 'Тип оружия',"
|
|
|
|
|
request += "`crystalls` int(11) NOT NULL COMMENT 'Кристаллы',"
|
|
|
|
|
request += "`created_at` datetime NOT NULL COMMENT 'Добавлен в базу',"
|
|
|
|
|
request += "PRIMARY KEY (`id`),"
|
|
|
|
|
request += "UNIQUE KEY `id` (`id`),"
|
|
|
|
|
request += "KEY `profiles_created_at` (`created_at`),"
|
|
|
|
|
request += "KEY `profiles_nickname` (`nickname`)"
|
2018-03-31 16:45:09 +04:00
|
|
|
|
request += ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='Профили зарегистрированных игроков'"
|
|
|
|
|
|
2017-11-14 03:44:21 +04:00
|
|
|
|
_, err := tx.Exec(request)
|
2018-03-31 16:45:09 +04:00
|
|
|
|
|
|
|
|
|
return err
|
2017-10-06 02:56:06 +04:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-14 03:44:21 +04:00
|
|
|
|
// CreateProfilesDown drops `profiles` table
|
2017-10-06 02:56:06 +04:00
|
|
|
|
func CreateProfilesDown(tx *sql.Tx) error {
|
2018-03-31 16:45:09 +04:00
|
|
|
|
_, err := tx.Exec("DROP TABLE `profiles`")
|
|
|
|
|
|
|
|
|
|
return err
|
2017-10-06 02:56:06 +04:00
|
|
|
|
}
|