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

43 lines
1.7 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// i2_bot Instinct PokememBro Bot
// Copyright (c) 2017-2018 Vladimir "fat0troll" Hodakov
package migrations
import (
"database/sql"
)
// CreatePokememesUp creates `pokememes` table
func CreatePokememesUp(tx *sql.Tx) error {
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`)"
request += ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='Покемемы'"
_, err := tx.Exec(request)
return err
}
// CreatePokememesDown drops `pokememes` table
func CreatePokememesDown(tx *sql.Tx) error {
_, err := tx.Exec("DROP TABLE `pokememes`")
return err
}