diff --git a/internal/dialect/dialectquery/postgres.go b/internal/dialect/dialectquery/postgres.go index a8df1397d..21ba63b36 100644 --- a/internal/dialect/dialectquery/postgres.go +++ b/internal/dialect/dialectquery/postgres.go @@ -45,12 +45,13 @@ func (p *Postgres) GetLatestVersion(tableName string) string { } func (p *Postgres) TableExists(tableName string) string { - q := `SELECT EXISTS ( SELECT 1 FROM pg_tables WHERE tablename = '%s' )` schemaName, tableName := parseTableIdentifier(tableName) if schemaName != "" { - q = `SELECT EXISTS ( SELECT 1 FROM pg_tables WHERE schemaname = '%s' AND tablename = '%s' )` + q := `SELECT EXISTS ( SELECT 1 FROM pg_tables WHERE schemaname = '%s' AND tablename = '%s' )` + return fmt.Sprintf(q, schemaName, tableName) } - return fmt.Sprintf(q, schemaName, tableName) + q := `SELECT EXISTS ( SELECT 1 FROM pg_tables WHERE tablename = '%s' )` + return fmt.Sprintf(q, tableName) } func parseTableIdentifier(name string) (schema, table string) {