Class: Strata::CLI::SubCommands::Create
- Inherits:
-
Thor
- Object
- Thor
- Strata::CLI::SubCommands::Create
- Extended by:
- Helpers::DescriptionHelper
- Includes:
- Guard, Helpers::CommandContext, Prompts, Terminal, Thor::Actions
- Defined in:
- lib/strata/cli/sub_commands/create.rb
Constant Summary
Constants included from DatasourceHelper
DatasourceHelper::ADAPTER_DRIVER_GEMS
Constants included from Prompts
Prompts::MIGRATION_HOOK_OPTIONS, Prompts::MSG_CONTINUE_NO_FIELDS, Prompts::MSG_CREATED_MODEL, Prompts::MSG_EDIT_MODEL_HINT, Prompts::MSG_FIELDS_CONFIRMED, Prompts::MSG_JOIN_CONDITION, Prompts::MSG_MODELS_COUNT, Prompts::MSG_MODELS_LIST_HEADER, Prompts::MSG_MODEL_DESCRIPTION, Prompts::MSG_MODEL_DISPLAY_NAME, Prompts::MSG_NO_FIELDS_CONFIRMED, Prompts::MSG_NO_MODELS_DIR, Prompts::MSG_NO_MODELS_FOUND, Prompts::MSG_NO_TABLES_FOUND, Prompts::MSG_RELATION_PATH, Prompts::MSG_SEARCH_TABLE, Prompts::MSG_SELECT_FROM_LIST, Prompts::MSG_SELECT_LEFT_TABLE, Prompts::MSG_SELECT_RIGHT_TABLE_ALL, Prompts::MSG_SELECT_RIGHT_TABLE_SUGGESTED, Prompts::MSG_SHOW_OTHER_TABLES
Constants included from Guard
Instance Method Summary collapse
- #migration(subcommand) ⇒ Object
- #migration_rename ⇒ Object
- #migration_swap ⇒ Object
- #relation(relation_path) ⇒ Object
- #table(table_path = nil) ⇒ Object
Methods included from Helpers::DescriptionHelper
Methods included from Helpers::CommandContext
#adapter, #all_tables, #datasource_key, #prompt, #table_fetch_result
Methods included from DatasourceHelper
#apply_readonly_mode, #create_adapter, #ds_config, #ensure_adapter_driver_gems!, #load_adapter_driver_gems!, #resolve_datasource, #resolve_datasource_value
Methods included from Prompts
Methods included from Terminal
#create_spinner, #print_table, #with_spinner
Methods included from Guard
Instance Method Details
#migration(subcommand) ⇒ Object
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/strata/cli/sub_commands/create.rb', line 69 def migration(subcommand) case subcommand when "rename" migration_rename when "swap" migration_swap else raise Strata::CommandError, "Unknown migration subcommand: #{subcommand}. Use 'rename' or 'swap'." end end |
#migration_rename ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/strata/cli/sub_commands/create.rb', line 88 def migration_rename validate_entity_type([:entity], "rename") validate_required_params([:entity], [:from], [:to]) hook = prompt_migration_hook("rename") create_rename_migration([:entity], [:from], [:to], hook) end |
#migration_swap ⇒ Object
104 105 106 107 108 109 110 |
# File 'lib/strata/cli/sub_commands/create.rb', line 104 def migration_swap validate_entity_type([:entity], "swap") validate_required_params([:entity], [:from], [:to]) hook = prompt_migration_hook("swap") create_swap_migration([:entity], [:from], [:to], hook) end |
#relation(relation_path) ⇒ Object
54 55 56 57 58 |
# File 'lib/strata/cli/sub_commands/create.rb', line 54 def relation(relation_path) return unless datasource_key create_relation_file(relation_path) end |
#table(table_path = nil) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/strata/cli/sub_commands/create.rb', line 37 def table(table_path = nil) return unless datasource_key # If table_path provided, skip search for speed if table_path handle_table_creation_with_path(table_path) else handle_table_creation_interactive end end |