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/3_create_profiles.go

44 lines
1.7 KiB
Go
Raw Normal View History

// i2_bot Instinct PokememBro Bot
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
package migrations
import (
2017-10-18 07:03:34 +04:00
"database/sql"
)
2017-11-14 03:44:21 +04:00
// CreateProfilesUp creates `profiles` table
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`)"
request += ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='Профили зарегистрированных игроков';"
_, err := tx.Exec(request)
2017-10-18 07:03:34 +04:00
if err != nil {
return err
}
return nil
}
2017-11-14 03:44:21 +04:00
// CreateProfilesDown drops `profiles` table
func CreateProfilesDown(tx *sql.Tx) error {
2017-10-18 07:03:34 +04:00
_, err := tx.Exec("DROP TABLE `profiles`;")
if err != nil {
return err
}
return nil
}