Sha256: 8603948eccf6c8458f7167145a849b65258514322fe2c7533ad2fc18f23f3b35

Contents?: true

Size: 1.33 KB

Versions: 6

Compression:

Stored size: 1.33 KB

Contents

require 'rails/generators/named_base'

# This class generates a migration file for deleting and creating
# a DynamoDB sessions table.
module DynamoDb
  module Generators
    # Generates an ActiveRecord migration that creates and deletes a DynamoDB
    # Session table.
    class SessionStoreMigrationGenerator < Rails::Generators::NamedBase
      include Rails::Generators::Migration

      source_root File.expand_path('templates', __dir__)

      # Desired name of migration class
      argument :name, type: :string, default: 'create_dynamo_db_sessions_table'

      # @return [Rails Migration File] migration file for creation and deletion
      #   of a DynamoDB session table.
      def generate_migration_file
        migration_template(
          'session_store_migration.erb',
          "db/migrate/#{name.underscore}.rb"
        )
      end

      def copy_sample_config_file
        template(
          'dynamo_db_session_store.yml',
          'config/dynamo_db_session_store.yml'
        )
      end

      # Next migration number - must be implemented
      def self.next_migration_number(_dir = nil)
        Time.now.utc.strftime('%Y%m%d%H%M%S')
      end

      private

      # @return [String] activerecord migration version
      def migration_version
        "#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}"
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
aws-sdk-rails-3.8.0 lib/generators/dynamo_db/session_store_migration/session_store_migration_generator.rb
aws-sdk-rails-3.7.1 lib/generators/dynamo_db/session_store_migration/session_store_migration_generator.rb
aws-sdk-rails-3.7.0 lib/generators/dynamo_db/session_store_migration/session_store_migration_generator.rb
aws-sdk-rails-3.6.4 lib/generators/dynamo_db/session_store_migration/session_store_migration_generator.rb
aws-sdk-rails-3.6.3 lib/generators/dynamo_db/session_store_migration/session_store_migration_generator.rb
aws-sdk-rails-3.6.2 lib/generators/dynamo_db/session_store_migration/session_store_migration_generator.rb