2017-10-06 02:56:06 +04:00
|
|
|
|
// i2_bot – Instinct PokememBro Bot
|
|
|
|
|
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
|
|
|
|
|
|
|
|
|
|
package migrations
|
|
|
|
|
|
|
|
|
|
import (
|
2017-10-18 07:03:34 +04:00
|
|
|
|
"github.com/pressly/goose"
|
2017-10-06 02:56:06 +04:00
|
|
|
|
)
|
|
|
|
|
|
2017-11-14 03:44:21 +04:00
|
|
|
|
// Init adds all migrations to applications
|
2017-10-06 02:56:06 +04:00
|
|
|
|
func (m *Migrations) Init() {
|
2017-11-14 03:44:21 +04:00
|
|
|
|
c.Log.Info("Initializing migrations...")
|
2017-10-18 07:03:34 +04:00
|
|
|
|
// All migrations are here
|
|
|
|
|
goose.AddNamedMigration("1_hello.go", HelloUp, nil)
|
|
|
|
|
goose.AddNamedMigration("2_create_players.go", CreatePlayersUp, CreatePlayersDown)
|
|
|
|
|
goose.AddNamedMigration("3_create_profiles.go", CreateProfilesUp, CreateProfilesDown)
|
|
|
|
|
goose.AddNamedMigration("4_create_pokememes.go", CreatePokememesUp, CreatePokememesDown)
|
|
|
|
|
goose.AddNamedMigration("5_create_locations.go", CreateLocationsUp, CreateLocationsDown)
|
|
|
|
|
goose.AddNamedMigration("6_create_elements.go", CreateElementsUp, CreateElementsDown)
|
|
|
|
|
goose.AddNamedMigration("7_create_leagues.go", CreateLeaguesUp, CreateLeaguesDown)
|
|
|
|
|
goose.AddNamedMigration("8_create_relations.go", CreateRelationsUp, CreateRelationsDown)
|
|
|
|
|
goose.AddNamedMigration("9_update_locations.go", UpdateLocationsUp, UpdateLocationsDown)
|
|
|
|
|
goose.AddNamedMigration("10_update_leagues.go", UpdateLeaguesUp, UpdateLeaguesDown)
|
|
|
|
|
goose.AddNamedMigration("11_profile_data_additions.go", ProfileDataAdditionsUp, ProfileDataAdditionsDown)
|
|
|
|
|
goose.AddNamedMigration("12_create_profile_relations.go", CreateProfileRelationsUp, CreateProfileRelationsDown)
|
|
|
|
|
goose.AddNamedMigration("13_create_weapons_and_add_wealth.go", CreateWeaponsAndAddWealthUp, CreateWeaponsAndAddWealthDown)
|
|
|
|
|
goose.AddNamedMigration("14_fix_time_element.go", FixTimeElementUp, FixTimeElementDown)
|
2017-10-18 09:39:50 +04:00
|
|
|
|
goose.AddNamedMigration("15_create_chats.go", CreateChatsUp, CreateChatsDown)
|
2017-10-21 14:14:46 +04:00
|
|
|
|
goose.AddNamedMigration("16_change_chat_type_column.go", ChangeChatTypeColumnUp, ChangeChatTypeColumnDown)
|
2017-10-22 13:13:20 +04:00
|
|
|
|
goose.AddNamedMigration("17_change_profile_pokememes_columns.go", ChangeProfilePokememesColumnsUp, ChangeProfilePokememesColumnsDown)
|
|
|
|
|
goose.AddNamedMigration("18_add_pokememes_wealth.go", AddPokememesWealthUp, AddPokememesWealthDown)
|
2017-10-22 15:29:48 +04:00
|
|
|
|
goose.AddNamedMigration("19_create_broadcasts.go", CreateBroadcastsUp, CreateBroadcastsDown)
|
2017-11-13 22:51:50 +04:00
|
|
|
|
goose.AddNamedMigration("20_create_squads.go", CreateSquadsUp, CreateSquadsDown)
|
2017-11-14 03:44:21 +04:00
|
|
|
|
goose.AddNamedMigration("21_change_telegram_id_column.go", ChangeTelegramIDColumnUp, ChangeTelegramIDColumnDown)
|
2017-11-19 22:16:11 +04:00
|
|
|
|
goose.AddNamedMigration("22_add_flood_chat_id.go", AddFloodChatIDUp, AddFloodChatIDDown)
|
2017-11-24 00:16:22 +04:00
|
|
|
|
goose.AddNamedMigration("23_add_user_type.go", AddUserTypeUp, AddUserTypeDown)
|
2017-11-26 15:28:55 +04:00
|
|
|
|
goose.AddNamedMigration("24_create_orders.go", CreateOrdersUp, CreateOrdersDown)
|
|
|
|
|
goose.AddNamedMigration("25_remove_reusable.go", RemoveReusableUp, RemoveReusableDown)
|
2017-11-26 19:38:25 +04:00
|
|
|
|
goose.AddNamedMigration("26_create_orders_completions.go", CreateOrdersCompletionsUp, CreateOrdersCompletionsDown)
|
|
|
|
|
goose.AddNamedMigration("27_add_new_weapon.go", AddNewWeaponUp, AddNewWeaponDown)
|
2017-12-22 22:20:52 +04:00
|
|
|
|
goose.AddNamedMigration("28_fix_locations.go", FixLocationsUp, FixLocationsDown)
|
|
|
|
|
goose.AddNamedMigration("29_fix_leagues_names.go", FixLeaguesNamesUp, FixLeaguesNamesDown)
|
2017-12-23 01:40:36 +04:00
|
|
|
|
goose.AddNamedMigration("30_create_alarms.go", CreateAlarmsUp, CreateAlarmsUp)
|
2017-10-06 02:56:06 +04:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-14 03:44:21 +04:00
|
|
|
|
// Migrate migrates database to current version
|
2017-10-06 02:56:06 +04:00
|
|
|
|
func (m *Migrations) Migrate() error {
|
2017-11-14 03:44:21 +04:00
|
|
|
|
c.Log.Printf("Starting database migrations...")
|
2017-10-18 07:03:34 +04:00
|
|
|
|
err := goose.Up(c.Db.DB, ".")
|
|
|
|
|
if err != nil {
|
2017-11-14 03:44:21 +04:00
|
|
|
|
c.Log.Fatal(err)
|
2017-10-06 02:56:06 +04:00
|
|
|
|
|
2017-10-18 07:03:34 +04:00
|
|
|
|
return err
|
|
|
|
|
}
|
2017-10-06 02:56:06 +04:00
|
|
|
|
|
2017-10-18 07:03:34 +04:00
|
|
|
|
return nil
|
2017-10-06 02:56:06 +04:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-14 03:44:21 +04:00
|
|
|
|
// SetDialect sets dialect for migrations
|
2017-10-06 02:56:06 +04:00
|
|
|
|
func (m *Migrations) SetDialect(dialect string) error {
|
2017-10-18 07:03:34 +04:00
|
|
|
|
return goose.SetDialect(dialect)
|
2017-10-06 02:56:06 +04:00
|
|
|
|
}
|