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

Version Path
activity_notification-2.3.3 lib/generators/activity_notification/migration/migration_generator.rb
activity_notification-2.3.2 lib/generators/activity_notification/migration/migration_generator.rb
activity_notification-2.3.1 lib/generators/activity_notification/migration/migration_generator.rb
activity_notification-2.3.0 lib/generators/activity_notification/migration/migration_generator.rb
activity_notification-2.2.4 lib/generators/activity_notification/migration/migration_generator.rb
activity_notification-2.2.3 lib/generators/activity_notification/migration/migration_generator.rb
activity_notification-2.2.2 lib/generators/activity_notification/migration/migration_generator.rb
activity_notification-2.2.1 lib/generators/activity_notification/migration/migration_generator.rb
activity_notification-2.2.0 lib/generators/activity_notification/migration/migration_generator.rb
activity_notification-2.1.4 lib/generators/activity_notification/migration/migration_generator.rb
activity_notification-2.1.3 lib/generators/activity_notification/migration/migration_generator.rb
activity_notification-2.1.2 lib/generators/activity_notification/migration/migration_generator.rb
activity_notification-2.1.1 lib/generators/activity_notification/migration/migration_generator.rb
activity_notification-2.1.0 lib/generators/activity_notification/migration/migration_generator.rb
activity_notification-2.0.0 lib/generators/activity_notification/migration/migration_generator.rb
activity_notification-1.7.1 lib/generators/activity_notification/migration/migration_generator.rb
activity_notification-1.7.0 lib/generators/activity_notification/migration/migration_generator.rb
activity_notification-1.6.1 lib/generators/activity_notification/migration/migration_generator.rb
activity_notification-1.6.0 lib/generators/activity_notification/migration/migration_generator.rb
activity_notification-1.5.1 lib/generators/activity_notification/migration/migration_generator.rb