Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Commit

Permalink
Fixed bug due to incorrect information_schema query for postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Kubb committed Jan 21, 2009
1 parent 7286cf9 commit 8591493
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lib/dm-core/adapters/postgres_adapter.rb
Expand Up @@ -18,27 +18,28 @@ def supports_returning?
module Migration
# TODO: move to dm-more/dm-migrations (if possible)
def storage_exists?(storage_name)
statement = <<-EOS.compress_lines
statement = <<-SQL.compress_lines
SELECT COUNT(*)
FROM "information_schema"."columns"
WHERE "table_name" = ?
FROM "information_schema"."tables"
WHERE "table_type" = 'BASE TABLE'
AND "table_schema" = current_schema()
EOS
AND "table_name" = ?
SQL

query(statement, storage_name).first > 0
end

# TODO: move to dm-more/dm-migrations (if possible)
def field_exists?(storage_name, column_name)
statement = <<-EOS.compress_lines
statement = <<-SQL.compress_lines
SELECT COUNT(*)
FROM "information_schema"."columns"
WHERE "table_name" = ?
WHERE "table_schema" = current_schema()
AND "table_name" = ?
AND "column_name" = ?
AND "table_schema" = current_schema()
EOS
SQL

query(statement, column_name, storage_name).first > 0
query(statement, storage_name, column_name).first > 0
end

# TODO: move to dm-more/dm-migrations
Expand Down

0 comments on commit 8591493

Please sign in to comment.