Loomio
Mon 25 Sep 2017 9:23PM

db:migrate fails on convert_motions_to_polls

PC Pablo Costa Public Seen by 393

Hi!

Today I attempted to upgrade our loomio-deploy instance; I was lagging behind something like 2 months.

When attempting to rake db:migrate, quite a lot of migrations went through with no issues, but the process breaks while "Migrating to DropMotionsAndVotes (20170705095538)".

The error I get is this:
NoMethodError: undefined method belongs_to' for Poll:Class
/loomio/db/migrate/legacy/models/poll.rb:2:in
'

I am attaching the console output for the rake db:migrate attempts.

I would really appreciate any hint to fix this issue even if by manually fiddling with the rails console and/or sql.

I have a database dump of the initial state (highest row in schema_migration is 20170705033454, i.e. add_subgroups_count_to_groups) but I don't have a clue of how to docker-compose the whole loomio-deploy stuff to the appropriate point in time. I feel so lame for not having a preproduction environment, but the server is too small... xD

Thanks a lot!

JK

James Kiesel Mon 25 Sep 2017 10:59PM

Hey @pablocosta,

I've pushed a fix for this in the latest master; try giving that a run?

PC

Pablo Costa Tue 26 Sep 2017 6:48AM

SO glad for the quick response @gdpelican :) thanks!

Now I get a different error:

root@loomio:/srv/loomio-deploy# docker-compose run loomio rake db:migrate
Creating loomiodeploy_db_1
Migrating to DropMotionsAndVotes (20170705095538)
== 20170705095538 DropMotionsAndVotes: migrating ==============================
converting 17 motions to polls
1
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

unknown attribute 'poll_options_attributes' for Poll.

[...]

/loomio/db/migrate/legacy/convert_motions_to_polls.rb:16:in `block in convert'
/loomio/db/migrate/legacy/convert_motions_to_polls.rb:10:in `map'
/loomio/db/migrate/legacy/convert_motions_to_polls.rb:10:in `convert'
/loomio/db/migrate/20170705095538_drop_motions_and_votes.rb:5:in `up'

Should I restore the original database or can I rely on the already applied migrations? Can you explain which commit(s) you applied and if docker-compose pull is enough to grab them all, or if e.g. I should remove the :stable from docker-compose image stances... I don't have a clear understanding of how the docker images relate to which branches/tags in the git repo.