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

Sequel migration issues #1520

Closed
leebrooks0 opened this Issue Dec 12, 2013 · 4 comments

Comments

Projects
None yet
4 participants
@leebrooks0

leebrooks0 commented Dec 12, 2013

I have been having some irritating issues migrating with Sequel,
I posted to the Sequel mailing list:

https://groups.google.com/forum/#!topic/sequel-talk/HOGcmez6u_8
https://groups.google.com/forum/#!topic/sequel-talk/Ki3T0bfBEkQ

and it was suggested that the loading of models during migrations is a Padrino bug, and that is what is causing all the problems. I personally don't really follow what is cutting here except that my migrations are not working :)

What I have done right now is just create a rake task following the suggestions given on the mailing list, and it does the trick, but I would prefer to come right with the Padrino one (sq:migrate) so that I can use it for test and production without my having to reinvent the wheel

task :migrate do
  `sequel -m db/migrate postgres://postgres:password@localhost/mobi_fit_development`
end
@jeremyevans

This comment has been minimized.

Show comment
Hide comment
@jeremyevans

jeremyevans Dec 13, 2013

The Sequel documentation explicitly warns against attempting to use models in migrations as it makes the migrations fragile, which is why I think this is a bug in Padrino.

jeremyevans commented Dec 13, 2013

The Sequel documentation explicitly warns against attempting to use models in migrations as it makes the migrations fragile, which is why I think this is a bug in Padrino.

@ujifgc

This comment has been minimized.

Show comment
Hide comment
@ujifgc

ujifgc Dec 13, 2013

Member

@leebrooks0 would you please sketch up a minimal project with failing models and migration, and publish it on github?

Member

ujifgc commented Dec 13, 2013

@leebrooks0 would you please sketch up a minimal project with failing models and migration, and publish it on github?

@leebrooks0

This comment has been minimized.

Show comment
Hide comment
@leebrooks0

leebrooks0 Dec 13, 2013

@ujifgc Sure: https://github.com/leebrooks0/padrino_sequel

To recreate the problem two things had to be done:
In a model I needed to specify the table, eg.

class User < Sequel::Model<<<(:users)>>>
end

and in the database.rb I had to load a Sequel plugin:

Sequel::Model.plugin(:schema)
<<<Sequel::Model.plugin(:auto_validations)>>>
Sequel::Model.raise_on_save_failure = false # Do not throw exceptions on failure
Sequel::Model.db = case Padrino.env
  when :development then Sequel.connect("postgres://localhost/padrino_sequel_development?user=postgres&password=password", :loggers => [logger])
  when :production  then Sequel.connect("postgres://localhost/padrino_sequel_production",  :loggers => [logger])
  when :test        then Sequel.connect("postgres://localhost/padrino_sequel_test",        :loggers => [logger])
end

This combination recreates the problem that I am experiencing.

leebrooks0 commented Dec 13, 2013

@ujifgc Sure: https://github.com/leebrooks0/padrino_sequel

To recreate the problem two things had to be done:
In a model I needed to specify the table, eg.

class User < Sequel::Model<<<(:users)>>>
end

and in the database.rb I had to load a Sequel plugin:

Sequel::Model.plugin(:schema)
<<<Sequel::Model.plugin(:auto_validations)>>>
Sequel::Model.raise_on_save_failure = false # Do not throw exceptions on failure
Sequel::Model.db = case Padrino.env
  when :development then Sequel.connect("postgres://localhost/padrino_sequel_development?user=postgres&password=password", :loggers => [logger])
  when :production  then Sequel.connect("postgres://localhost/padrino_sequel_production",  :loggers => [logger])
  when :test        then Sequel.connect("postgres://localhost/padrino_sequel_test",        :loggers => [logger])
end

This combination recreates the problem that I am experiencing.

@ghost ghost assigned ujifgc Dec 31, 2013

@nesquena

This comment has been minimized.

Show comment
Hide comment
@nesquena

nesquena Jan 2, 2014

Member

Is this fixed then?

Member

nesquena commented Jan 2, 2014

Is this fixed then?

@ujifgc ujifgc closed this in c63ff2c Jan 2, 2014

ujifgc added a commit that referenced this issue Jan 2, 2014

Merge pull request #1542 from padrino/1520-fix-sequel-migration
Skip loading models for sequel migration tasks, closes #1520

Ortuna added a commit to Ortuna/padrino-framework that referenced this issue Jan 17, 2014

ujifgc added a commit that referenced this issue Oct 28, 2014

Merge pull request #1799 from padrino/fix-1795
better patch for #1520, load missing models for sq:seed, fixes #1795
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment