Sha256: e80cb5dc0cd58e00d4fe59eaec264fd4af4cac35df459ecce1c08ff0d23e9812
Contents?: true
Size: 1023 Bytes
Versions: 30
Compression:
Stored size: 1023 Bytes
Contents
require 'rails/generators/active_record' module ActivityNotification module Generators # Migration generator to create migration files from templates. # @example Run migration generator # rails generate activity_notification:migration class MigrationGenerator < ActiveRecord::Generators::Base MIGRATION_TABLES = ['notifications', 'subscriptions'].freeze source_root File.expand_path("../../../templates/migrations", __FILE__) argument :name, type: :string, default: 'CreateActivityNotificationTables', desc: "The migration name to create tables" class_option :tables, aliases: "-t", type: :array, desc: "Select specific tables to generate (#{MIGRATION_TABLES.join(', ')})" # Create migration files in application directory def create_migrations @migration_name = name @migration_tables = options[:tables] || MIGRATION_TABLES migration_template 'migration.rb', "db/migrate/#{name.underscore}.rb" end end end end
Version data entries
30 entries across 30 versions & 1 rubygems