Skip to content

Commit

Permalink
Update migration base class to work with new versions of Rails (#1041)
Browse files Browse the repository at this point in the history
What?
=====

Rails' migrations now support versioning; this updates the superclass to
conditionally swap based on versions of Rails to remove a deprecation
warning.
  • Loading branch information
joshuaclayton authored Sep 28, 2017
1 parent dd420df commit f48b90a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions features/support/factories.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:database => File.join(File.dirname(__FILE__), 'test.db')
adapter: 'sqlite3',
database: File.join(File.dirname(__FILE__), 'test.db')
)

class CreateSchema < ActiveRecord::Migration
migration_class =
if ActiveRecord::Migration.respond_to?(:[])
ActiveRecord::Migration[4.2]
else
ActiveRecord::Migration
end

class CreateSchema < migration_class
def self.up
create_table :categories, :force => true do |t|
create_table :categories, force: true do |t|
t.string :name
end
end
Expand Down

0 comments on commit f48b90a

Please sign in to comment.