Skip to content
Closed
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
18 changes: 16 additions & 2 deletions lib/apartment/adapters/postgresql_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,28 @@ def preserving_search_path
#
def clone_pg_schema
pg_schema_sql = patch_search_path(pg_dump_schema)
Apartment.connection.execute(pg_schema_sql)

# Create a temporary file to store the SQL
Tempfile.create do |temp_file|
temp_file.write(pg_schema_sql)
temp_file.close # Close the file so psql can read it

with_pg_env { system("psql", "-q", "-d", dbname, "-f", temp_file.path) }
end
end

# Copy data from schema_migrations into new schema
#
def copy_schema_migrations
pg_migrations_data = patch_search_path(pg_dump_schema_migrations_data)
Apartment.connection.execute(pg_migrations_data)

# Create a temporary file to store the SQL
Tempfile.create do |temp_file|
temp_file.write(pg_migrations_data)
temp_file.close # Close the file so psql can read it

with_pg_env { system("psql", "-q", "-d", dbname, "-f", temp_file.path) }
end
end

# Dump postgres default schema
Expand Down
Loading