1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-24 17:04:43 +00:00

Added a separate table to record background job status for tournaments and fixed migrations/schemas for solid dbs. Foreign key constraints are now added to the migrations where we do belongs_to.

This commit is contained in:
2025-04-15 16:16:44 -04:00
parent 4828d9b876
commit 6e61a7245a
37 changed files with 678 additions and 1169 deletions

View File

@@ -23,7 +23,7 @@ module Wrestling
# Configure schema dumping for multiple databases
config.active_record.schema_format = :ruby
config.active_record.dump_schemas = :individual
config.active_record.dump_schemas = :all
# Fix deprecation warning for to_time in Rails 8.1
config.active_support.to_time_preserves_timezone = :zone

View File

@@ -23,15 +23,19 @@ development:
primary:
<<: *default
database: db/development.sqlite3
migrations_paths: db/migrate
queue:
<<: *default
database: db/development-queue.sqlite3
migrations_paths: db/queue/migrate
cache:
<<: *default
database: db/development-cache.sqlite3
migrations_paths: db/cache/migrate
cable:
<<: *default
database: db/development-cable.sqlite3
migrations_paths: db/cable/migrate
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
@@ -40,15 +44,19 @@ test:
primary:
<<: *default
database: db/test.sqlite3
migrations_paths: db/migrate
queue:
<<: *default
database: db/test-queue.sqlite3
migrations_paths: db/queue/migrate
cache:
<<: *default
database: db/test-cache.sqlite3
migrations_paths: db/cache/migrate
cable:
<<: *default
database: db/test-cable.sqlite3
migrations_paths: db/cable/migrate
production:
primary:
@@ -59,6 +67,7 @@ production:
password: <%= ENV['WRESTLINGDEV_DB_PWD'] %>
host: <%= ENV['WRESTLINGDEV_DB_HOST'] %>
port: <%= ENV['WRESTLINGDEV_DB_PORT'] %>
migrations_paths: db/migrate
queue:
adapter: mysql2
encoding: utf8
@@ -67,6 +76,7 @@ production:
password: <%= ENV['WRESTLINGDEV_DB_PWD'] %>
host: <%= ENV['WRESTLINGDEV_DB_HOST'] %>
port: <%= ENV['WRESTLINGDEV_DB_PORT'] %>
migrations_paths: db/queue/migrate
cache:
adapter: mysql2
encoding: utf8
@@ -75,6 +85,7 @@ production:
password: <%= ENV['WRESTLINGDEV_DB_PWD'] %>
host: <%= ENV['WRESTLINGDEV_DB_HOST'] %>
port: <%= ENV['WRESTLINGDEV_DB_PORT'] %>
migrations_paths: db/cache/migrate
cable:
adapter: mysql2
encoding: utf8
@@ -83,4 +94,5 @@ production:
password: <%= ENV['WRESTLINGDEV_DB_PWD'] %>
host: <%= ENV['WRESTLINGDEV_DB_HOST'] %>
port: <%= ENV['WRESTLINGDEV_DB_PORT'] %>
migrations_paths: db/cable/migrate

View File

@@ -34,24 +34,15 @@ Rails.application.configure do
# Don't use connects_to here since it's configured via cache.yml
# config.solid_cache.connects_to = { database: { writing: :cache } }
# Configure path for cache migrations
config.paths["db/migrate"] << "db/cache/migrate"
# Configure Solid Queue as the ActiveJob queue adapter
config.active_job.queue_adapter = :solid_queue
# Don't use connects_to here since it's configured via queue.yml
# config.solid_queue.connects_to = { database: { writing: :queue } }
# Configure path for queue migrations
config.paths["db/migrate"] << "db/queue/migrate"
# Configure ActionCable to use its own database
# Don't use connects_to here since it's configured via cable.yml
# config.action_cable.connects_to = { database: { writing: :cable } }
# Configure path for cable migrations
config.paths["db/migrate"] << "db/cable/migrate"
# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :local
@@ -98,4 +89,10 @@ Rails.application.configure do
#Bullet.console = true
#Bullet.bullet_logger = true
end
# Raise error on unpermitted parameters, because we want to be sure we're catching them all.
config.action_controller.action_on_unpermitted_parameters = :raise
# Dump the schema after migrations
config.active_record.dump_schema_after_migration = true
end

View File

@@ -59,8 +59,8 @@ Rails.application.configure do
# Replace the default in-process and non-durable queuing backend for Active Job.
config.active_job.queue_adapter = :solid_queue
# Don't use connects_to here since it's configured via queue.yml
# config.solid_queue.connects_to = { database: { writing: :queue } }
# Configure Solid Queue to use the queue database
config.solid_queue.connects_to = { database: { writing: :queue, reading: :queue } }
# Configure path for queue migrations
config.paths["db/migrate"] << "db/queue/migrate"

View File

@@ -15,52 +15,3 @@ else
# In test, use inline adapter for simplicity
Rails.application.config.active_job.queue_adapter = :inline
end
# Register the custom attributes we want to track
module SolidQueueConfig
mattr_accessor :job_owner_tracking_enabled, default: true
end
# Define ActiveJobExtensions - this should match what's already being used in ApplicationJob
module ActiveJobExtensions
extend ActiveSupport::Concern
included do
attr_accessor :job_owner_id, :job_owner_type
end
end
# Solid Queue adapter hooks to save job owner info to columns
module SolidQueueAdapterExtensions
def enqueue(job)
job_data = job.serialize
job_id = super
# Store job owner info after job is created
if defined?(SolidQueue::Job) && job_data["job_owner_id"].present?
Rails.logger.info("Setting job_owner for SolidQueue job #{job_id}: #{job_data["job_owner_id"]}, #{job_data["job_owner_type"]}")
begin
# Use execute_query for direct SQL to bypass any potential ActiveRecord issues
ActiveRecord::Base.connection.execute(
"UPDATE solid_queue_jobs SET job_owner_id = #{ActiveRecord::Base.connection.quote(job_data["job_owner_id"])}, " +
"job_owner_type = #{ActiveRecord::Base.connection.quote(job_data["job_owner_type"])} " +
"WHERE id = #{job_id}"
)
Rails.logger.info("Successfully updated job_owner info for job #{job_id}")
rescue => e
Rails.logger.error("Error updating job_owner info: #{e.message}")
end
end
job_id
end
end
# Apply extensions
Rails.application.config.after_initialize do
# Add extensions to ActiveJob::QueueAdapters::SolidQueueAdapter if defined
if defined?(ActiveJob::QueueAdapters::SolidQueueAdapter)
Rails.logger.info("Applying SolidQueueAdapterExtensions")
ActiveJob::QueueAdapters::SolidQueueAdapter.prepend(SolidQueueAdapterExtensions)
end
end