-
Notifications
You must be signed in to change notification settings - Fork 10
/
migrations.go
43 lines (36 loc) · 1.4 KB
/
migrations.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright (C) 2015 TF2Stadium
// Use of this source code is governed by the GPLv3
// that can be found in the COPYING file.
package migrations
import (
"sync"
"github.com/TF2Stadium/Helen/database"
"github.com/TF2Stadium/Helen/models"
"github.com/TF2Stadium/Helen/models/chat"
"github.com/TF2Stadium/Helen/models/gameserver"
"github.com/TF2Stadium/Helen/models/lobby"
"github.com/TF2Stadium/Helen/models/player"
)
var once = new(sync.Once)
func Do() {
database.DB.Exec("CREATE EXTENSION IF NOT EXISTS hstore")
database.DB.AutoMigrate(&player.Player{})
database.DB.AutoMigrate(&lobby.Lobby{})
database.DB.AutoMigrate(&lobby.LobbySlot{})
database.DB.AutoMigrate(&gameserver.ServerRecord{})
database.DB.AutoMigrate(&player.PlayerStats{})
database.DB.AutoMigrate(&models.AdminLogEntry{})
database.DB.AutoMigrate(&player.PlayerBan{})
database.DB.AutoMigrate(&chat.ChatMessage{})
database.DB.AutoMigrate(&lobby.Requirement{})
database.DB.AutoMigrate(&Constant{})
database.DB.AutoMigrate(&gameserver.StoredServer{})
database.DB.AutoMigrate(&player.Report{})
database.DB.Model(&lobby.LobbySlot{}).
AddUniqueIndex("idx_lobby_slot_lobby_id_slot", "lobby_id", "slot")
database.DB.Model(&lobby.LobbySlot{}).
AddUniqueIndex("idx_lobby_id_player_id", "lobby_id", "player_id")
database.DB.Model(&lobby.LobbySlot{}).
AddUniqueIndex("idx_requirement_lobby_id_slot", "lobby_id", "slot")
once.Do(checkSchema)
}