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
Vladimir Hodakov 4abfc457ce Add return constants package, and common message sender functions
Trying to resolve as much as possible ``gometalinter`` issues.
2018-03-31 16:45:09 +04:00

41 lines
1.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// i2_bot Instinct PokememBro Bot
// Copyright (c) 2017-2018 Vladimir "fat0troll" Hodakov
package migrations
import (
"database/sql"
)
// CreateProfilesUp creates `profiles` table
func CreateProfilesUp(tx *sql.Tx) error {
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)
return err
}
// CreateProfilesDown drops `profiles` table
func CreateProfilesDown(tx *sql.Tx) error {
_, err := tx.Exec("DROP TABLE `profiles`")
return err
}