fix schema for postgres

This commit is contained in:
Lunny Xiao 2018-04-10 00:05:20 +08:00
parent 0177c08cee
commit cb67f794ce
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
2 changed files with 4 additions and 1 deletions

View File

@ -149,7 +149,8 @@ func (db *Base) SupportDropIfExists() bool {
} }
func (db *Base) DropTableSql(tableName string) string { func (db *Base) DropTableSql(tableName string) string {
return fmt.Sprintf("DROP TABLE IF EXISTS `%s`", tableName) quote := db.dialect.Quote
return fmt.Sprintf("DROP TABLE IF EXISTS %s", quote(tableName))
} }
func (db *Base) HasRecords(query string, args ...interface{}) (bool, error) { func (db *Base) HasRecords(query string, args ...interface{}) (bool, error) {

View File

@ -22,6 +22,8 @@ type Index struct {
func (index *Index) XName(tableName string) string { func (index *Index) XName(tableName string) string {
if !strings.HasPrefix(index.Name, "UQE_") && if !strings.HasPrefix(index.Name, "UQE_") &&
!strings.HasPrefix(index.Name, "IDX_") { !strings.HasPrefix(index.Name, "IDX_") {
tableName = strings.Replace(tableName, `"`, "", -1)
tableName = strings.Replace(tableName, `.`, "_", -1)
if index.Type == UniqueType { if index.Type == UniqueType {
return fmt.Sprintf("UQE_%v_%v", tableName, index.Name) return fmt.Sprintf("UQE_%v_%v", tableName, index.Name)
} }