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/migrations.go

54 lines
2.3 KiB
Go
Raw Normal View History

// i2_bot Instinct PokememBro Bot
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
package migrations
import (
2017-10-18 07:03:34 +04:00
// stdlib
"log"
// 3rd-party
"github.com/pressly/goose"
)
2017-10-18 07:03:34 +04:00
type Migrations struct{}
func (m *Migrations) Init() {
2017-10-18 07:03:34 +04:00
log.Printf("Initializing migrations...")
// 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)
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)
goose.AddNamedMigration("17_change_profile_pokememes_columns.go", ChangeProfilePokememesColumnsUp, ChangeProfilePokememesColumnsDown)
goose.AddNamedMigration("18_add_pokememes_wealth.go", AddPokememesWealthUp, AddPokememesWealthDown)
goose.AddNamedMigration("19_create_broadcasts.go", CreateBroadcastsUp, CreateBroadcastsDown)
}
func (m *Migrations) Migrate() error {
2017-10-18 07:03:34 +04:00
log.Printf("Starting database migrations...")
err := goose.Up(c.Db.DB, ".")
if err != nil {
log.Fatal(err)
2017-10-18 07:03:34 +04:00
return err
}
2017-10-18 07:03:34 +04:00
return nil
}
func (m *Migrations) SetDialect(dialect string) error {
2017-10-18 07:03:34 +04:00
return goose.SetDialect(dialect)
}