This project is archived and is in readonly mode.
[Patch] Rails schema_format :sql should behave like schema_format :ruby
Reported by Nick Gauthier | August 19th, 2010 @ 07:44 PM
When ActiveRecord::Base.schema_format is set to :sql it should mimic the behavior of :ruby (db/schema.rb).
I've created a patch that maintains all the existing rake targets (like db:reset, db:migrate, db:setup, etc.) and toggles between the tasks appropriately.
I also added a db:structure:load task so that it could be toggled with db:schema:load.
I've attached the patch. I tried to keep with the conventions found in the existing file.
Note that there are a few other tickets similar to this one. However, the only ticket of those with a patch creates extra and differently named rails tasks, which does not accomplish the goal I attained here. The other tickets are merely feature requests.
-Nick Gauthier
Comments and changes to this ticket
-
Nick Gauthier August 19th, 2010 @ 08:11 PM
- Title changed from Rails schema_format :sql should behave like schema_format :ruby to [Patch] Rails schema_format :sql should behave like schema_format :ruby
-
Dave Hoover September 15th, 2010 @ 08:58 PM
This seems like exactly what I need (since we switched to schema_format = :sql) but I'm wondering why you switched to structure.sql from {env}_structure.sql.
-
Nick Gauthier September 15th, 2010 @ 09:02 PM
Because if I migrate the dev db, then run the tests, if I left it with env_structure if would do this:
1) Run db/migrate
=> updated dev_structure.sql 2) Run tests
=> load from test_structure.sql (FILE MISSING)But if you just use structure.sql (like schema.rb), then they can use the same structure file.
The main reason can be summarize to: I want to mimic schema dumping and loading as closely as possible.
-Nick Gauthier
-
Dave Hoover September 15th, 2010 @ 09:15 PM
Thanks Nick.
And BTW, great job on your talk at Windy City Rails. I couldn't be there, but I heard it was one of the better talks of the day. :)
-
Gaius Centus Novus October 29th, 2010 @ 07:13 PM
See also #5889, which backports these changes to Rails 2.3
-
Jeff Kreeftmeijer November 8th, 2010 @ 08:52 AM
- Tag cleared.
- Importance changed from to Low
Automatic cleanup of spam.
-
Gabriel Sobrinho January 24th, 2011 @ 08:02 PM
Waiting for this patch too.
This patch apply for rails 3?
-
William Denniss February 18th, 2011 @ 05:41 AM
+1 I would really like to see the sql option become a first class citizen, especially since it is presented that way in the docs ( http://guides.rubyonrails.org/migrations.html#types-of-schema-dumps )
-
Brad Langhorst April 6th, 2011 @ 04:33 PM
updated the patch so that it uses the logic in test:clone_structure for db:structure:load instead of executing the lines in the structure file. test:clone_structure now uses db:structure:load just like test:clone does to db:schema:load
fixed things so that setup loads the environment before trying to use it where necessary (db:reset and db:setup)
added respect for the PGUSER environment variable, eliminating the -U from dump and load statements (needed for trust and ident authentication)
patch is diffed against rails 2.3.11.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 5235 config.active_record.schema_format = :sql #5412
- 2789 Make Rake task db:schema:load compatible with SQL schema format I'll mark this as a duplicate then.#5412
- 5889 [Patch] Rails 2.3 schema_format :sql should behave like schema_format :ruby This backports the patch in #5412 to 2-3-stable.