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
|
|
|
|
// CreatePokememesUp creates `pokememes` table
|
2017-10-06 02:56:06 +04:00
|
|
|
|
func CreatePokememesUp(tx *sql.Tx) error {
|
2017-11-14 03:44:21 +04:00
|
|
|
|
request := "CREATE TABLE `pokememes` ("
|
|
|
|
|
request += "`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID покемема',"
|
|
|
|
|
request += "`grade` int(11) NOT NULL COMMENT 'Поколение покемема',"
|
|
|
|
|
request += "`name` varchar(191) NOT NULL COMMENT 'Имя покемема',"
|
|
|
|
|
request += "`description` TEXT NOT NULL COMMENT 'Описание покемема',"
|
|
|
|
|
request += "`attack` int(11) NOT NULL COMMENT 'Атака',"
|
|
|
|
|
request += "`hp` int(11) NOT NULL COMMENT 'Здоровье',"
|
|
|
|
|
request += "`mp` int(11) NOT NULL COMMENT 'МР',"
|
|
|
|
|
request += "`defence` int(11) NOT NULL COMMENT 'Защита',"
|
|
|
|
|
request += "`price` int(11) NOT NULL COMMENT 'Стоимость',"
|
|
|
|
|
request += "`purchaseable` bool NOT NULL DEFAULT true COMMENT 'Можно купить?',"
|
|
|
|
|
request += "`image_url` varchar(191) NOT NULL COMMENT 'Изображение покемема',"
|
|
|
|
|
request += "`player_id` int(11) NOT NULL COMMENT 'Кто добавил в базу',"
|
|
|
|
|
request += "`created_at` datetime NOT NULL COMMENT 'Добавлен в базу',"
|
|
|
|
|
request += "PRIMARY KEY (`id`),"
|
|
|
|
|
request += "UNIQUE KEY `id` (`id`),"
|
|
|
|
|
request += "KEY `pokememes_created_at` (`created_at`),"
|
|
|
|
|
request += "KEY `pokememes_player_id` (`player_id`)"
|
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
|
|
|
|
// CreatePokememesDown drops `pokememes` table
|
2017-10-06 02:56:06 +04:00
|
|
|
|
func CreatePokememesDown(tx *sql.Tx) error {
|
2018-03-31 16:45:09 +04:00
|
|
|
|
_, err := tx.Exec("DROP TABLE `pokememes`")
|
|
|
|
|
|
|
|
|
|
return err
|
2017-10-06 02:56:06 +04:00
|
|
|
|
}
|