Sha256: ac3b33e75547dbd29540dfd81ec152c25e468de12f2967fe57ffc220dcc86543
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
require "rails/generators" require "rails/generators/active_record" # This generator adds a migration for the {FriendlyId::History # FriendlyId::History} addon. class AcidicJobGenerator < ActiveRecord::Generators::Base # ActiveRecord::Generators::Base inherits from Rails::Generators::NamedBase which requires a NAME parameter for the # new table name. Our generator always uses 'acidic_job_keys', so we just set a random name here. argument :name, type: :string, default: "random_name" source_root File.expand_path("templates", __dir__) def self.next_migration_number(_path) if instance_variable_defined?("@prev_migration_nr") @prev_migration_nr += 1 else @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i end @prev_migration_nr.to_s end # Copies the migration template to db/migrate. def copy_files migration_template "migration.rb", "db/migrate/create_acidid_job_keys.rb" end protected def migration_class if ActiveRecord::VERSION::MAJOR >= 5 ActiveRecord::Migration["#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"] else ActiveRecord::Migration end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acidic_job-0.2.0 | lib/generators/acidic_job_generator.rb |