Class: ClickhouseRuby::Generators::MigrationGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
ActiveRecord::Generators::Migration
Defined in:
lib/clickhouse_ruby/active_record/generators/migration_generator.rb

Overview

Rails generator for creating ClickHouse migrations

This generator creates migration files with ClickHouse-specific options like ENGINE, ORDER BY, PARTITION BY, and PRIMARY KEY.

Examples:

Generate a migration

rails generate clickhouse:migration CreateEvents

Generate a migration with columns

rails generate clickhouse:migration CreateEvents user_id:integer name:string

Generate a migration with ClickHouse options

rails generate clickhouse:migration CreateEvents user_id:integer --engine=ReplacingMergeTree --order-by=user_id

Instance Method Summary collapse

Instance Method Details

#create_migration_filevoid

This method returns an undefined value.

Generate the migration file



57
58
59
60
61
62
# File 'lib/clickhouse_ruby/active_record/generators/migration_generator.rb', line 57

def create_migration_file
  set_local_assigns!
  validate_engine!

  migration_template "migration.rb.tt", File.join(db_migrate_path, "#{file_name}.rb")
end