Class: StructuredStore::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/structured_store/generators/install_generator.rb

Overview

This generator creates a migration for the structured store versioned schemas table

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(_dirname) ⇒ Object

This method is required when including Rails::Generators::Migration



15
16
17
# File 'lib/structured_store/generators/install_generator.rb', line 15

def self.next_migration_number(_dirname)
  Time.now.utc.strftime('%Y%m%d%H%M%S')
end

Instance Method Details

#create_migration_fileObject



19
20
21
# File 'lib/structured_store/generators/install_generator.rb', line 19

def create_migration_file
  migration_template 'create_structured_store.rb', 'db/migrate/create_structured_store.rb'
end

#create_schemas_directoryObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/structured_store/generators/install_generator.rb', line 23

def create_schemas_directory
  directory_path = 'db/structured_store_versioned_schemas'
  keep_file_path = File.join(directory_path, '.keep')

  # Create the directory if it doesn't exist
  empty_directory directory_path

  # Create the .keep file
  create_file keep_file_path
end