mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Fixing postgres issue and bumping version number
This commit is contained in:
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
const (
|
||||
VERSION_MAJOR = 0
|
||||
VERSION_MINOR = 7
|
||||
VERSION_MINOR = 8
|
||||
VERSION_PATCH = 0
|
||||
BUILD_NUMBER = "_BUILD_NUMBER_"
|
||||
BUILD_DATE = "_BUILD_DATE_"
|
||||
|
||||
@@ -77,8 +77,10 @@ func NewSqlStore() Store {
|
||||
}
|
||||
|
||||
// Temporary upgrade code, remove after 0.8.0 release
|
||||
if sqlStore.DoesColumnExist("Sessions", "AltId") {
|
||||
sqlStore.GetMaster().Exec("DROP TABLE IF EXISTS Sessions")
|
||||
if sqlStore.DoesTableExist("Sessions") {
|
||||
if sqlStore.DoesColumnExist("Sessions", "AltId") {
|
||||
sqlStore.GetMaster().Exec("DROP TABLE IF EXISTS Sessions")
|
||||
}
|
||||
}
|
||||
|
||||
sqlStore.team = NewSqlTeamStore(sqlStore)
|
||||
@@ -169,6 +171,51 @@ func (ss SqlStore) GetCurrentSchemaVersion() string {
|
||||
return version
|
||||
}
|
||||
|
||||
func (ss SqlStore) DoesTableExist(tableName string) bool {
|
||||
if utils.Cfg.SqlSettings.DriverName == "postgres" {
|
||||
count, err := ss.GetMaster().SelectInt(
|
||||
`SELECT count(relname) FROM pg_class WHERE relname=$1`,
|
||||
strings.ToLower(tableName),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
l4g.Critical("Failed to check if table exists %v", err)
|
||||
time.Sleep(time.Second)
|
||||
panic("Failed to check if table exists " + err.Error())
|
||||
}
|
||||
|
||||
return count > 0
|
||||
|
||||
} else if utils.Cfg.SqlSettings.DriverName == "mysql" {
|
||||
|
||||
count, err := ss.GetMaster().SelectInt(
|
||||
`SELECT
|
||||
COUNT(0) AS table_exists
|
||||
FROM
|
||||
information_schema.TABLES
|
||||
WHERE
|
||||
TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = ?
|
||||
`,
|
||||
tableName,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
l4g.Critical("Failed to check if table exists %v", err)
|
||||
time.Sleep(time.Second)
|
||||
panic("Failed to check if table exists " + err.Error())
|
||||
}
|
||||
|
||||
return count > 0
|
||||
|
||||
} else {
|
||||
l4g.Critical("Failed to check if column exists because of missing driver")
|
||||
time.Sleep(time.Second)
|
||||
panic("Failed to check if column exists because of missing driver")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (ss SqlStore) DoesColumnExist(tableName string, columnName string) bool {
|
||||
if utils.Cfg.SqlSettings.DriverName == "postgres" {
|
||||
count, err := ss.GetMaster().SelectInt(
|
||||
|
||||
Reference in New Issue
Block a user