GithubHelp home page GithubHelp logo

Comments (4)

DyegoCosta avatar DyegoCosta commented on September 18, 2024

@cyberdelia did you mean to add it to the template spec_helper? I think it's a good idea as well, I can add that check

I believe we have two options here, use the Sequel default error message

Sequel::Migrator.check_current(DB, "#{Config.root}/db/migrate")
$ rake                                                                      [ruby-2.2.1]
rake aborted!
Sequel::Migrator::NotCurrentError: migrator is not current
/Users/dyego/.rvm/gems/ruby-2.2.1/gems/sequel-4.24.0/lib/sequel/extensions/migration.rb:368:in `check_current'
/Users/dyego/code/magenta/spec/spec_helper.rb:11:in `<top (required)>'
/Users/dyego/.rvm/gems/ruby-2.2.1/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1280:in `require'
...
Tasks: TOP => default => spec
(See full trace by running task with --trace)

Or check if it's current and fail with our own error message

unless Sequel::Migrator.if_current(DB, "#{Config.root}/db/migrate")
  fail "Our own error message"
end

Do you think we need a custom message or Sequel's default is fine?

from pliny.

cyberdelia avatar cyberdelia commented on September 18, 2024

I would rather have the migration applied rather than just a check, but that could be a could be a good first step.

from pliny.

gudmundur avatar gudmundur commented on September 18, 2024

I like the idea, yet I'm reluctant to running the migrations automatically. If we do, then what should we do with the -development database? Often you'll also want your tests to pass, even though you haven't migrated the database. The example I'm thinking here is where you have deployed things, but migrations haven't run yet.

I think the nice thing to do here is to give a warning. What do you think?

from pliny.

cyberdelia avatar cyberdelia commented on September 18, 2024

The main goal would be to avoid running tests against an outdated schema. What we currently do is:

begin
  require "sequel/extensions/migration"
  Sequel::Migrator.check_current(Sequel::Model.db, 'db/migrate')
rescue Sequel::Migrator::Error
  abort("Test database is not up-to-date, please run: bundle exec rake db:setup")
end

from pliny.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.