gorm/dialect_postgres_go1.8.go
2017-11-18 18:04:41 +03:30

35 lines
1.0 KiB
Go

// +build go1.8
package gorm
import "context"
func (s postgres) HasIndex(tableName string, indexName string) bool {
var count int
s.db.QueryRowContext(context.Background(), queryPostgresHasIndex, tableName, indexName).Scan(&count)
return count > 0
}
func (s postgres) HasForeignKey(tableName string, foreignKeyName string) bool {
var count int
s.db.QueryRowContext(context.Background(), queryPostgresHasForeignKey, tableName, foreignKeyName).Scan(&count)
return count > 0
}
func (s postgres) HasTable(tableName string) bool {
var count int
s.db.QueryRowContext(context.Background(), queryPostgresHasTable, tableName).Scan(&count)
return count > 0
}
func (s postgres) HasColumn(tableName string, columnName string) bool {
var count int
s.db.QueryRowContext(context.Background(), queryPostgresHasColumn, tableName, columnName).Scan(&count)
return count > 0
}
func (s postgres) CurrentDatabase() (name string) {
s.db.QueryRowContext(context.Background(), queryPostgresCurrentDatabase).Scan(&name)
return
}