Skip to content

Commit

Permalink
backward comp: deprecation warning ✔️
Browse files Browse the repository at this point in the history
  • Loading branch information
mistersourcerer committed Sep 30, 2012
1 parent 7c38f2a commit 2435cbc
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
12 changes: 11 additions & 1 deletion lib/standalone_migrations/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module StandaloneMigrations
class Tasks
class << self
def configure
Deprecations.new.call
config_database_file = Configurator.new.config
paths = Rails.application.config.paths
paths.add "config/database", :with => config_database_file
Expand All @@ -11,8 +12,17 @@ def load_tasks
configure

MinimalRailtieConfig.load_tasks
load "active_record/railties/databases.rake"
load "standalone_migrations/tasks/connection.rake"
load "standalone_migrations/tasks/environment.rake"
load "active_record/railties/databases.rake"
end
end
end

class Tasks::Deprecations
def call
if File.directory?('db/migrations')
puts "DEPRECATED move your migrations into db/migrate"
end
end
end
Expand Down
8 changes: 5 additions & 3 deletions lib/standalone_migrations/tasks/connection.rake
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require File.expand_path("../../../standalone_migrations", __FILE__)
task :environment do
configurator = StandaloneMigrations::Configurator.new
ActiveRecord::Base.establish_connection configurator.config_for(Rails.env)
namespace :standalone do
task :connection do
configurator = StandaloneMigrations::Configurator.new
ActiveRecord::Base.establish_connection configurator.config_for(Rails.env)
end
end
3 changes: 3 additions & 0 deletions lib/standalone_migrations/tasks/environment.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require File.expand_path("../../../standalone_migrations", __FILE__)
task environment: ["standalone:connection"] do
end
5 changes: 5 additions & 0 deletions spec/standalone_migrations_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
describe 'Standalone migrations' do

def write(file, content)
raise "cannot write nil" unless file
file = tmp_file(file)
Expand Down Expand Up @@ -88,6 +89,10 @@ def down
TXT
end

after(:all) do
`rm -rf spec/tmp` if File.exist?('spec/tmp')
end

it "warns of deprecated folder structure" do
warning = /DEPRECATED.* db\/migrate/
run("rake db:create").should_not =~ warning
Expand Down

0 comments on commit 2435cbc

Please sign in to comment.