From f48b90a95afe6fbbf527abc446db34ee12b3e173 Mon Sep 17 00:00:00 2001 From: Josh Clayton Date: Thu, 28 Sep 2017 09:31:29 -0400 Subject: [PATCH] Update migration base class to work with new versions of Rails (#1041) What? ===== Rails' migrations now support versioning; this updates the superclass to conditionally swap based on versions of Rails to remove a deprecation warning. --- features/support/factories.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/features/support/factories.rb b/features/support/factories.rb index 8b69959..35edb95 100644 --- a/features/support/factories.rb +++ b/features/support/factories.rb @@ -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