Sha256: e203ca32359a323e51c73e4ba5d4b56e626fa459dc4a3f7bd3046cc6335dec60
Contents?: true
Size: 1.02 KB
Versions: 7
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true require "rails/generators" require "rails/generators/active_record" module PaperTrail # Basic structure to support a generator that builds a migration class MigrationGenerator < ::Rails::Generators::Base include ::Rails::Generators::Migration def self.next_migration_number(dirname) ::ActiveRecord::Generators::Base.next_migration_number(dirname) end protected def add_paper_trail_migration(template, extra_options = {}) migration_dir = File.expand_path("db/migrate") if self.class.migration_exists?(migration_dir, template) ::Kernel.warn "Migration already exists: #{template}" else migration_template( "#{template}.rb.erb", "db/migrate/#{template}.rb", { migration_version: migration_version }.merge(extra_options) ) end end def migration_version major = ActiveRecord::VERSION::MAJOR if major >= 5 "[#{major}.#{ActiveRecord::VERSION::MINOR}]" end end end end
Version data entries
7 entries across 7 versions & 1 rubygems