-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
4.0.0.rc2, Postgres UUID primary keys: db:schema:load doesn't create the table properly; db:migrate does #11016
Comments
I'm seeing this issue too, and I just updated to Rails 4.0.0. It's a bit curious because there is also this issue: Unfortunately, now that I check this out, it doesn't look like it made it into the 4.0.0 release; the released version in 4.0.0 still doesn't have the fix: I'm guessing that this will get fixed in a bug release relatively soon. Until then, I guess we have to use db:migrate to set up our test db. |
Whew! Glad to know I'm not the only one here! Thanks for the info, @decasia! |
Yes, that fix will go out in 4.0.1. Thanks so much for digging into it, @decasia |
Thanks for all the detail in here guys. Great work. And here is my workaround until 4.0.1 drops https://gist.github.com/joshuacronemeyer/7049936 in case it helps anybody else. |
I'm still having this issue in 4.0.1. Didn't it make the cut to be included ? For the record @joshuacronemeyer's solution works. |
No, 4d3eee6 doesn't seem to be included in 4.0.1, nor in 4.0.2 (since it was a security release). |
@steveklabnik any objection to reopening this since it hasn't gone out in a release yet? |
It doesn't need to be re-opened, as the fix has landed. I'm not sure why it wasn't in 4.0.1, exactly. @carlosantoniodasilva do you know? |
Unless i am missing something u can always use structure.sql (rake db:structure:dump) , thereby removing the need for using schema.rb (preferred way when using postgres). Remove schema.rb and set in config/application.rb config.active_record.schema_format :sql Rspec will use db:structure.load instead of db:schema:load |
any news on this ? |
Worked for me. I'm using pg's |
I'm using Rails 4.0.0.rc2 with Postgres 9.2.4 and trying to use the new UUID-as-primary-key feature, but I'm running into some inconsistencies with rake tasks. I'd initially posted the problem here: http://stackoverflow.com/questions/17178497/rspec-rails-4-postgres-uuid-primary-keys-id-is-null-with-rake-rspec-but-i, but in a nutshell the problem is this: when I use
rake db:migrate
to create the table with the UUID primary keys, I can then create new model objects just fine; when I userake db:schema:load
, I cannot then create new model objects.My migration:
...creates this schema:
When I
rake db:drop && rake db:create && rake db:migrate
, I see:...and thus:
(horray!) ...yet when I
rake db:drop && rake db:create && rake db:schema:load
, I see:Notice how the growers table's :id is created using
{ :id => false, :force => true }
instead of{ :id => :uuid }
. ...and consequently, when I try to create a Grower object, I get:This seems to make sense based on the given schema (I think?), and thus it seems like the schema.rb that's generated is incorrect.
Initially, I encountered this because I'm using RSpec and
rake spec
uses thedb:schema:load
task, which was thus causing much head-to-wall-banging as I couldn't figure out why things seemed fine until I ran my tests using Rake. I can continue running the tests without using rake, but it'd be really nice to use that again.The text was updated successfully, but these errors were encountered: