fractaledmind / enlitenment

A Rails application template script to lead your app to SQLite enlightenment.
44 stars 3 forks source link

Bad database.yml after applying template to fresh rails 8.0.0.beta1 installation #13

Open erikbelusic opened 3 weeks ago

erikbelusic commented 3 weeks ago

Describe the bug With new rails 8.0.0.beta1 the database.yml file has duplicate keys for cache, queue, and cable

To Reproduce Pre-req - have the rails 8.0.0.1 gem installed.

➜ rails -v
Rails 8.0.0.beta1

Create a new rails app

rails new my-app

Apply the template (cd into rails app directory)

cd my-app
INSTALL_INTO="application" rails app:template \
  LOCATION=https://raw.githubusercontent.com/fractaledmind/enlitenment/main/template.rb

database.yml BEFORE

# SQLite. Versions 3.8.0 and up are supported.
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem "sqlite3"
#
default: &default
  adapter: sqlite3
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  timeout: 5000

development:
  <<: *default
  database: storage/development.sqlite3

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  <<: *default
  database: storage/test.sqlite3

# Store production database in the storage/ directory, which by default
# is mounted as a persistent Docker volume in config/deploy.yml.
production:
  primary:
    <<: *default
    database: storage/production.sqlite3
  cache:
    <<: *default
    database: storage/production_cache.sqlite3
    migrations_paths: db/cache_migrate
  queue:
    <<: *default
    database: storage/production_queue.sqlite3
    migrations_paths: db/queue_migrate
  cable:
    <<: *default
    database: storage/production_cable.sqlite3
    migrations_paths: db/cable_migrate

database.yml AFTER

# SQLite. Versions 3.8.0 and up are supported.
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem "sqlite3"
#
default: &default
  adapter: sqlite3
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  timeout: 5000

errors: &errors
  <<: *default
  migrations_paths: db/errors_migrate
  database: storage/<%= Rails.env %>-errors.sqlite3

cable: &cable
  <<: *default
  migrations_paths: db/cable_migrate
  database: storage/<%= Rails.env %>-cable.sqlite3

cache: &cache
  <<: *default
  migrations_paths: db/cache_migrate
  database: storage/<%= Rails.env %>-cache.sqlite3

queue: &queue
  <<: *default
  migrations_paths: db/queue_migrate
  database: storage/<%= Rails.env %>-queue.sqlite3

development:
  primary:
    <<: *default
    database: storage/development.sqlite3
  queue: *queue
  cache: *cache
  cable: *cable
  errors: *errors

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  primary:
    <<: *default
    database: storage/test.sqlite3
  queue: *queue
  cache: *cache
  cable: *cable
  errors: *errors

# Store production database in the storage/ directory, which by default
# is mounted as a persistent Docker volume in config/deploy.yml.
production:
  primary:
    <<: *default
    database: storage/production.sqlite3
  cache:
    <<: *default
    database: storage/production_cache.sqlite3
    migrations_paths: db/cache_migrate
  queue:
    <<: *default
    database: storage/production_queue.sqlite3
    migrations_paths: db/queue_migrate
  cable:
    <<: *default
    database: storage/production_cable.sqlite3
    migrations_paths: db/cable_migrate
  queue: *queue
  cache: *cache
  cable: *cable
  errors: *errors

Expected behavior Only one key for each DB exists in the production section

diff --git a/config/database.yml b/config/database.yml
index e9b89a5..c329ed7 100644
--- a/config/database.yml
+++ b/config/database.yml
@@ -57,18 +57,6 @@ production:
   primary:
     <<: *default
     database: storage/production.sqlite3
-  cache:
-    <<: *default
-    database: storage/production_cache.sqlite3
-    migrations_paths: db/cache_migrate
-  queue:
-    <<: *default
-    database: storage/production_queue.sqlite3
-    migrations_paths: db/queue_migrate
-  cable:
-    <<: *default
-    database: storage/production_cable.sqlite3
-    migrations_paths: db/cable_migrate
   queue: *queue
   cache: *cache
   cable: *cable

Additional context I assume when the beta was released, the database.yml template changed from when this template was authored from the pre-release version