-
Notifications
You must be signed in to change notification settings - Fork 86
schema_plus 2.0.0.pre2 in Padrino throws NoMethodError when encountering FKs #201
Comments
@fj First, thanks for trying out the prerelease! But hmm, i'm not able to reproduce that. It's vaguely possible it was fixed by a fix i pushed to schema_monkey earlier today. If you're not using schema_monkey 0.3.2 could you bundle update and try again? If that doesn't fix it, can you send me more details? ruby version, Gemfile.lock, schema.rb. or even the entire failing app if that's something you can distribute. (email or gist is fine) |
Sure. I'll investigate this today and see if I can get something for you. I confirmed the bug is still there (for me) even after updating. |
Thanks. FYI I just released 2.0.0.pre2, can you try it with that instead? I don't expect it to fix your problem. But then again, I don't know what's causing your problem, so it's hard to say :) BTW 2.0.0.pre1 won't work any more if you update, because of a breaking change in schema_monkey 0.3.0 -> 0.4.0 (I should have made a major version bump in schema_monkey, but since the only thing that I know of that it breaks is the prerelease, I let it slide.) |
I updated to schema_plus 2.0.0.pre2. With the following schema, I get the error every time using ActiveRecord 4.2, and running
and the error is:
|
Does |
Yes it does -- actually in this case the missing methods are supposed to be added to Which db gem / connection adapter are you using? vanilla " |
Just vanilla |
Oh, I just noticed: Padrino. That explains it. SchemaPlus (actually SchemaMonkey) relies on a rails I'm not terribly familiar with Padrino, so I'm not certain the appropriate way to do this, but you need to arrange to call For rails, that actually happens in two places: in an Do you want to try to get it working for Padrino? If there's some elegant way to package it up for Padrino I'd be happy to include it in SchemaPlus/SchemaMonkey. Now that you bring this up, SchemaPlus has no reason for an explicit dependency on rails, it should just depend on activerecord. But it should recognize if rails is loaded and if so do the Railtie thing. And ideally similarly recognize if Padrino is loaded and if so do whatever the Padrino thing is |
Yeah, Padrino doesn't really have anything like Railties unless you're integrating with something Padrino-specific (which you aren't). So I don't think this would be too hard to make work -- it looks like the only thing that actually needs to happen is a call to Generally the convention I see is that if people want to support different framework-specific integrations, one does something like There's also the gem-specific route (e.g. Anyway, if you're okay with unconditional loads then the Padrino integration is probably just this one-liner:
and then the Rake tasks are something like
WDYT? |
(Of course, that all presumes that |
Your point about detecting Rails/Padrino/etc is well taken. But checking But yes, for Padrino it may as well be explicit. Including the integrations in So how about a new gem # schema_plus_padrino.rb
module SchemaPlusPadrino
def self.insert
SchemaMonkey.insert
end
end
# schema_plus_padrino/rake.rb
require 'schema_monkey/rake'
SchemaMonkey::Rake.insert("ar:schema:dump", "ar:schema:load") and integration would be like: # your Gemfile
gem "schema_plus"
gem "schema_plus_padrino"
# your app
SchemaPlusPadrino.insert
# your Rakefile
require 'schema_plus_padrino/rake' WDYT? |
Sure, that'd work. That's what I was describing with the The only small correction is that you'd probably want it to be |
thanks for the concern! honestly, i'm hoping/planning that by breaking schema_plus into a bunch of small pieces, it'll be overall easier to maintain. and hopefully i won't have to be the one doing the heavy lifting of maintaining them all; if nothing else having small single-purpose gems should make it easier for people to submit PRs (BTW If you're planning on using schema_plus 2.x with padrino, would you like to be the owner of schema_plus_padrino?)
Yeah, I've been going back and forth on that. Since I'm making a whole family of gems named SchemaPlusXxxx, should they all be in a SchemaPlus namespace? That has a certain aesthetic appeal. On the other hand, the gems are all supposed to be independent of each other, and I do really like the strict convention that a gem defines its own top-level module. |
I'd be happy to share responsibility, but I think you should at least be co-maintainer (otherwise, if you needed to fix something and you couldn't reach me on short notice, that would be bad). |
FYI I made schema_monkey_rails, pulling the Railtie stuff out of [schema_monkey](https://github.com/SchemaPlus/schema_monkey. What pushed me over the edge was realizing that making a proper rspec for the Railtie requires pulling in rails, which muddies up the test environment; by pulling the Railtie out, (My backwards-compatibility thing still works because the So at some point you or I can make |
Thanks @ronen. I'm going to start with just a couple of |
@fj I've created schema_monkey_padrino, along the above lines, and listed you as a co-owner (gem) and collaborator (github). Since I don't really know Padrino, could you....
Once it's ready either one of us should be able to Oh BTW I just released schema_plus 2.0.0.pre3 which uses schema_monkey 1.0, that would be the best one to test with now. Cheers |
Thanks! I'm a little slammed and traveling this week but I'll look at it this weekend for sure. |
@fj Schema_monkey now inserts itself, no explicit insertion step is necessary. So schema_monkey_rails and schema_monkey_padrino are no longer needed. (I've retired schema_monkey_rails.) I just released schema_plus 2.0.0.pre8, if you update to that you should be able to remove any insertion stuff in the main code or in rake tasks. |
Following up on this: I just had an opportunity to upgrade schema_plus, but it's not clear to me how an arbitrary task will get This does seem to work for my purposes, so I think we can close this if you're in agreement. |
Yes, just |
👍 |
When running
db:schema:load
and encountering a foreign key, the prerelease version throws aNoMethodError
:You can reproduce this by just having
in a schema and running
db:schema:load
.The text was updated successfully, but these errors were encountered: