Auto-ignore models without structure block
Closed this issue · 4 comments
I have acts-as-taggable-on
plugin installed. When I run rake generate migrations
it's prompting me to delete the context and created_at columns. It's also generating all sorts of migrations to affect indexes, which I don't want.
The reason I believe is because they have a belongs_to
call, which is initializing the schema. The thing is though, the taggable model doesn't initialize any other schema via the structure block. So either you only acts on models in app/models (which will mean gems won't be able to utilize migrant), or the better solution:
Ignore models unless structure block was specifically called.
def structure(type=nil, &block)
@initialized ||= true
...
end
def generate_migrations
models.select(&:initialized?).each { ... }
end
Your assumption about the belongs_to was correct, in fact Migrant should not affect models that don't define a structure block in any way. I've added a commit that should address this.
I'm not certain whether this fixes your taggable problem however, but please feel free to try the master branch and let me know what you find.
If this resolves the problem I'll push a patch ASAP, after I've done a few sanity checks.