Class: Nvoi::Cli::Onboard::Steps::Database

Inherits:
Object
  • Object
show all
Includes:
Ui
Defined in:
lib/nvoi/cli/onboard/steps/database.rb

Overview

Collects database configuration

Constant Summary collapse

DATABASES =
[
  { name: "PostgreSQL", value: { adapter: "postgresql", image: "postgres:17-alpine" } },
  { name: "PostgreSQL + pgvector", value: { adapter: "postgresql", image: "pgvector/pgvector:pg17" } },
  { name: "MySQL", value: { adapter: "mysql", image: "mysql:8" } },
  { name: "SQLite", value: { adapter: "sqlite3", image: nil } },
  { name: "None (skip)", value: nil }
].freeze

Constants included from Ui

Ui::MAX_RETRIES

Instance Method Summary collapse

Methods included from Ui

#box, #error, #output, #prompt_with_retry, #section, #success, #table, #with_spinner

Constructor Details

#initialize(prompt, test_mode: false) ⇒ Database

Returns a new instance of Database.



19
20
21
22
# File 'lib/nvoi/cli/onboard/steps/database.rb', line 19

def initialize(prompt, test_mode: false)
  @prompt = prompt
  @test_mode = test_mode
end

Instance Method Details

#call(app_name:, existing: nil) ⇒ Object

Returns [db_config, volume_config] tuple



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/nvoi/cli/onboard/steps/database.rb', line 25

def call(app_name:, existing: nil)
  section "Database"

  selection = @prompt.select("Database:", DATABASES)
  return [nil, nil] unless selection

  case selection[:adapter]
  when "postgresql" then setup_postgres(app_name, selection[:image])
  when "mysql"      then setup_mysql(app_name, selection[:image])
  when "sqlite3"    then setup_sqlite
  end
end