Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/also_migrate/migrator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ def create_tables(config)
CREATE TABLE #{new_table}
(#{col_string})
SQL
elsif connection.class.to_s.include?('PostgreSQL')
# Postgres patch
# 1. Valid table creation
# "CREATE TABLE XXX LIKE YYY" is invalid
# "CREATE TABLE XXX ( LIKE YYY )" is a correct one
# 2. Add primary key to new table
connection.execute(<<-SQL)
CREATE TABLE #{new_table}
(LIKE #{config[:source]} INCLUDING INDEXES);
SQL
else
connection.execute(<<-SQL)
CREATE TABLE #{new_table}
Expand Down Expand Up @@ -96,4 +106,4 @@ def create_tables(config)
end
end
end
end
end