# Primary database: PostgreSQL for network intelligence
# Cache/Queue/Cable: SQLite for auxiliary storage

# Default configuration for SQLite databases (cache/queue/cable)
sqlite_default: &sqlite_default
  adapter: sqlite3
  max_connections: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  timeout: 5000

# Default configuration for PostgreSQL
postgres_default: &postgres_default
  adapter: postgresql
  encoding: unicode
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  host: localhost
  port: 5432

development:
  primary:
    <<: *postgres_default
    database: baffle_hub_development
  cache:
    <<: *sqlite_default
    database: storage/development_cache.sqlite3
    migrations_paths: db/cache_migrate
  queue:
    <<: *sqlite_default
    database: storage/development_queue.sqlite3
    migrations_paths: db/queue_migrate
  cable:
    <<: *sqlite_default
    database: storage/development_cable.sqlite3
    migrations_paths: db/cable_migrate

test:
  primary:
    <<: *postgres_default
    database: baffle_hub_test
  cache:
    <<: *sqlite_default
    database: storage/test_cache.sqlite3
    migrations_paths: db/cache_migrate
  queue:
    <<: *sqlite_default
    database: storage/test_queue.sqlite3
    migrations_paths: db/queue_migrate
  cable:
    <<: *sqlite_default
    database: storage/test_cable.sqlite3
    migrations_paths: db/cable_migrate

production:
  primary:
    <<: *postgres_default
    database: baffle_hub_production
    username: baffle_hub
    password: <%= ENV["BAFFLE_HUB_DATABASE_PASSWORD"] %>
  cache:
    <<: *sqlite_default
    database: storage/production_cache.sqlite3
    migrations_paths: db/cache_migrate
  queue:
    <<: *sqlite_default
    database: storage/production_queue.sqlite3
    migrations_paths: db/queue_migrate
  cable:
    <<: *sqlite_default
    database: storage/production_cable.sqlite3
    migrations_paths: db/cable_migrate
