Running migrations in different PostgreSQL schemas is inconsistent #896

Closed
lighthouse-import opened this Issue May 16, 2011 · 1 comment

Comments

Projects
None yet
2 participants

Imported from Lighthouse. Original ticket at: http://rails.lighthouseapp.com/projects/8994/tickets/6520
Created by Jigar Patel - 2011-03-04 12:40:13 UTC

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?

svenfuchs pushed a commit to svenfuchs/rails that referenced this issue Jul 2, 2011

Don't rewrap system level exceptions with StatementInvalid
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#896 state:committed]

??? it's bug or normal?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment