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/4_create_pokememes.go

46 lines
1.8 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 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)
if err != nil {
return err
}
return nil
}
// CreatePokememesDown drops `pokememes` table
func CreatePokememesDown(tx *sql.Tx) error {
_, err := tx.Exec("DROP TABLE `pokememes`;")
if err != nil {
return err
}
return nil
}