Skip to content

Commit

Permalink
Merge pull request TalentBox#25 from rudle/migrations-are-in-rails-root
Browse files Browse the repository at this point in the history
Use fully qualified directory path for migrations
  • Loading branch information
JonathanTron committed Apr 3, 2013
2 parents b6f2a87 + d46f0c0 commit f75403f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/sequel_rails/migrations.rb
Expand Up @@ -6,14 +6,14 @@ class << self
def migrate(version=nil)
opts = {}
opts[:target] = version.to_i if version
::Sequel::Migrator.run(::Sequel::Model.db, "db/migrate", opts)
::Sequel::Migrator.run(::Sequel::Model.db, Rails.root.join("db/migrate"), opts)
end
alias_method :migrate_up!, :migrate
alias_method :migrate_down!, :migrate

def pending_migrations?
return false unless File.exists?("db/migrate")
!::Sequel::Migrator.is_current?(::Sequel::Model.db, "db/migrate")
return false unless File.exists?(Rails.root.join("db/migrate"))
!::Sequel::Migrator.is_current?(::Sequel::Model.db, Rails.root.join("db/migrate"))
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions spec/lib/sequel_rails/migrations_spec.rb
Expand Up @@ -11,7 +11,7 @@
let(:opts) { {} }
it "runs migrations using Sequel::Migrator" do
::Sequel::Migrator.should_receive(:run).with(
db, "db/migrate", opts
db, Rails.root.join("db/migrate"), opts
).and_return result
described_class.send(migration_method).should be result
end
Expand All @@ -20,7 +20,7 @@
let(:opts) { {:target => 1} }
it "runs migrations using Sequel::Migrator" do
::Sequel::Migrator.should_receive(:run).with(
db, "db/migrate", opts
db, Rails.root.join("db/migrate"), opts
).and_return result
described_class.send(migration_method, 1).should be result
end
Expand All @@ -30,7 +30,7 @@

describe ".pending_migrations?" do
include FakeFS::SpecHelpers
let(:path) { "db/migrate" }
let(:path) { Rails.root.join("db/migrate") }

it "returns false if no db/migrate directory exists" do
described_class.pending_migrations?.should == false
Expand All @@ -41,14 +41,14 @@

it "returns true if any pending migration" do
::Sequel::Migrator.should_receive(:is_current?).with(
db, "db/migrate"
db, Rails.root.join("db/migrate")
).and_return false
described_class.pending_migrations?.should == true
end

it "returns false if no pending migration" do
::Sequel::Migrator.should_receive(:is_current?).with(
db, "db/migrate"
db, Rails.root.join("db/migrate")
).and_return true
described_class.pending_migrations?.should == false
end
Expand Down

0 comments on commit f75403f

Please sign in to comment.