Description
I hope there is a better way to do this that I am not seeing.
According to the read me:
Then run db:prepare in production to ensure the database is created and the schema is loaded.
I am testing this out in staging first. So I ran the following on the server:
RAILS_ENV=staging bin/rails db:prepare
This did nothing to the queue database. Maybe because the queue database already existed? Our deployment process sets up the databases ahead of time. So running this command resulted in zero tables in the queue DB. Plus, db:prepare is not listed as a command for multiple databases. However, db:setup is. So, I ran:
RAILS_ENV=staging bin/rails db:setup:queue
This might have worked. However, it tried connecting to the postgres database. Presumably to drop and recreate the database. However, connecting as postgres is not allowed on our staging and production systems.
So, I tried db:schema:load:queue (I actually tried this first):
RAILS_ENV=staging bin/rails db:schema:load:queue
This resulted in this error:
bin/rails aborted!
TypeError: Invalid type for configuration. Expected Symbol, String, or Hash. Got nil (TypeError)
raise TypeError, "Invalid type for configuration. Expected Symbol, String, or Hash. Got #{config.inspect}"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Tasks: TOP => db:schema:load:queue => db:test:purge:queue
It looks like it is doing something with regard to a test DB that does not exist? There is actually an open PR about this: rails/rails#50672.
Then I started a console in the Staging environment on the server and ran these commands to load the schema in the queue database:
ActiveRecord::Base.establish_connection(:queue)
load Rails.root.join('db','queue_schema.rb')
This successfully loaded the queue database.
Is there a better way to do this? I don't remember having to load a schema in Staging or Production before. It seems like an anti-pattern? I started using Solid Queue with version 0.3 and the migrations sure seemed easier. Would it be easier to place the contents of the queue_schema.rb in a single migration file?
Activity