lib/generators/draftsman/install_generator.rb in draftsman-0.7.0 vs lib/generators/draftsman/install_generator.rb in draftsman-0.7.1
- old
+ new
@@ -1,9 +1,11 @@
require 'rails/generators'
require 'rails/generators/migration'
require 'rails/generators/active_record'
+require 'support/feature_detection'
+
module Draftsman
class InstallGenerator < ::Rails::Generators::Base
include ::Rails::Generators::Migration
desc 'Creates config initializer and generates (but does not run) a migration to add a drafts table.'
@@ -11,22 +13,29 @@
class_option :skip_initializer, :type => :boolean, :default => false, :desc => 'Skip generation of the boilerplate initializer at `config/initializers/draftsman.rb`.'
class_option :with_changes, :type => :boolean, :default => false, :desc => 'Store changeset (diff) with each draft.'
class_option :with_pg_json, :type => :boolean, :default => false, :desc => 'Use PostgreSQL JSON data type for serialized data.'
def create_migration_file
+
+ config = {
+ api_version: activerecord_migrations_versioned? ? '[4.2]' : ''
+ }
+
if options.with_pg_json?
- migration_template 'create_drafts_json.rb', 'db/migrate/create_drafts.rb'
+ migration_template 'create_drafts_json.rb', 'db/migrate/create_drafts.rb', config
if options.with_changes?
migration_template 'add_object_changes_column_to_drafts_json.rb',
- 'db/migrate/add_object_changes_column_to_drafts.rb'
+ 'db/migrate/add_object_changes_column_to_drafts.rb',
+ config
end
else
- migration_template 'create_drafts.rb', 'db/migrate/create_drafts.rb'
+ migration_template 'create_drafts.rb', 'db/migrate/create_drafts.rb', config
if options.with_changes?
migration_template 'add_object_changes_column_to_drafts.rb',
- 'db/migrate/add_object_changes_column_to_drafts.rb'
+ 'db/migrate/add_object_changes_column_to_drafts.rb',
+ config
end
end
end
def self.next_migration_number(dirname)