Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Running migrations in different PostgreSQL schemas is inconsistent

#6520

Hello,

I have been researching on using multiple Postgres schemas in a single rails app. One option is to develop the entire app in one schema (default schema) and then create other shemas and dump the database structure in them. Other option is to support running migrations in specified schema and maintain the schema_migrations table in each schema.

I have made some patches, but I am not sure of the correctness of the approach. Here is what I have done -
1. Modify this method - ActiveRecord::Migrator.schema_migrations_table_name - to return the sm_table name as schema_name.table_name if the adapter is PostgreSQL.
2. Add an option of specifying the schema name in migration rake tasks.

This would result in this flow -
rake db:migrate SCHEMA=demo

Rake tasks will have following steps -
a) Set current schema search path
b) Run the migration (as it is done now)
c) Set schema_search_path to old schema search path.

Now a developer can develop in a "dev" schema, and run the migration in any specified schema or all the schemas.

Can somebody guide me, so that I can write test cases for this?

Reported by Jigar Patel · March 4th, 2011 @ 12:40 PM

State: new
Milestone: none
Assigned to: Pratik Pratik
Importance: none

Activity

No comments yet.