Sha256: 5f82aac7338e9a0baf05e454c7ba6bc8ed2710112f623b6d8c4b9c493bc736a3

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

require 'rails/generators'

# @api private
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 the migration class
      argument :name,
               desc: 'Optional name of the migration class',
               type: :string,
               default: 'create_dynamo_db_sessions_table'

      def generate_migration_file
        migration_template(
          'session_store_migration.erb',
          "db/migrate/#{name.underscore}.rb"
        )
      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

      def migration_version
        "#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
aws-actiondispatch-dynamodb-1.0.0 lib/generators/dynamo_db/session_store_migration/session_store_migration_generator.rb
aws-actiondispatch-dynamodb-0.2.0 lib/generators/dynamo_db/session_store_migration/session_store_migration_generator.rb
aws-actiondispatch-dynamodb-0.1.0 lib/generators/dynamo_db/session_store_migration/session_store_migration_generator.rb