Fixing postgres issue and bumping version number
Этот коммит содержится в:
@@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
VERSION_MAJOR = 0
|
VERSION_MAJOR = 0
|
||||||
VERSION_MINOR = 7
|
VERSION_MINOR = 8
|
||||||
VERSION_PATCH = 0
|
VERSION_PATCH = 0
|
||||||
BUILD_NUMBER = "_BUILD_NUMBER_"
|
BUILD_NUMBER = "_BUILD_NUMBER_"
|
||||||
BUILD_DATE = "_BUILD_DATE_"
|
BUILD_DATE = "_BUILD_DATE_"
|
||||||
|
|||||||
@@ -77,8 +77,10 @@ func NewSqlStore() Store {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Temporary upgrade code, remove after 0.8.0 release
|
// Temporary upgrade code, remove after 0.8.0 release
|
||||||
if sqlStore.DoesColumnExist("Sessions", "AltId") {
|
if sqlStore.DoesTableExist("Sessions") {
|
||||||
sqlStore.GetMaster().Exec("DROP TABLE IF EXISTS Sessions")
|
if sqlStore.DoesColumnExist("Sessions", "AltId") {
|
||||||
|
sqlStore.GetMaster().Exec("DROP TABLE IF EXISTS Sessions")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlStore.team = NewSqlTeamStore(sqlStore)
|
sqlStore.team = NewSqlTeamStore(sqlStore)
|
||||||
@@ -169,6 +171,51 @@ func (ss SqlStore) GetCurrentSchemaVersion() string {
|
|||||||
return version
|
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 {
|
func (ss SqlStore) DoesColumnExist(tableName string, columnName string) bool {
|
||||||
if utils.Cfg.SqlSettings.DriverName == "postgres" {
|
if utils.Cfg.SqlSettings.DriverName == "postgres" {
|
||||||
count, err := ss.GetMaster().SelectInt(
|
count, err := ss.GetMaster().SelectInt(
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user