Commit c7e3ed09 by Torkel Ödegaard

fix(postgres): fixes db migration issue with_credentials column for postgres, fixes #3505

parent 10f66fa7
......@@ -55,7 +55,7 @@ func (col *Column) StringNoPk(d Dialect) string {
}
if col.Default != "" {
sql += "DEFAULT " + col.Default + " "
sql += "DEFAULT " + d.Default(col) + " "
}
return sql
......
......@@ -17,10 +17,11 @@ type Dialect interface {
SqlType(col *Column) string
SupportEngine() bool
LikeStr() string
Default(col *Column) string
CreateIndexSql(tableName string, index *Index) string
CreateTableSql(table *Table) string
AddColumnSql(tableName string, Col *Column) string
AddColumnSql(tableName string, col *Column) string
CopyTableData(sourceTable string, targetTable string, sourceCols []string, targetCols []string) string
DropTable(tableName string) string
DropIndexSql(tableName string, index *Index) string
......@@ -71,6 +72,10 @@ func (b *BaseDialect) EqStr() string {
return "="
}
func (b *BaseDialect) Default(col *Column) string {
return col.Default
}
func (b *BaseDialect) CreateTableSql(table *Table) string {
var sql string
sql = "CREATE TABLE IF NOT EXISTS "
......
......@@ -36,6 +36,17 @@ func (db *Postgres) AutoIncrStr() string {
return ""
}
func (b *Postgres) Default(col *Column) string {
if col.Type == DB_Bool {
if col.Default == "0" {
return "FALSE"
} else {
return "TRUE"
}
}
return col.Default
}
func (db *Postgres) SqlType(c *Column) string {
var res string
switch t := c.Type; t {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment