Skip to content

Conversation

@christinach
Copy link
Member

@christinach christinach commented Dec 12, 2025

  • Remove ActiveRecord::Migration.check_all_pending! Only verify DB connection
  • Create new dir for the rom migrations
  • Add new rake task for rom migrations: bundle exec rake rom:migrate
  • Add rake task to fix auto-increment sequences on existing tables
  • Convert Rails migrations to Sequel format migrations
  • Add rake task to mark migrations that have already applied

ROM migration:

  • uses Sequel.migration do instead of class ..< ActiveRecord::Migration
  • we need to declare explicitly primary_key :id
  • String instead of string - DateTime, Date instead of datetime
  • Adds a new sequel_schema_migrations table

related to [#403]

when you checkout the branch:
lando destroy
bundle exec rake servers:start
RAILS_ENV=test bundle exec rake rom:migrate
bundle exec rspec

Also load the application locally and run some queries to make sure everything is working locally.

@christinach christinach force-pushed the 403-database-rom branch 20 times, most recently from a923834 to ac8f241 Compare December 16, 2025 17:06
christinach and others added 2 commits December 16, 2025 12:11
* Remove ActiveRecord::Migration.check_all_pending! Only verify DB connection
* Create new dir for the rom migrations
* Add new rake task for rom migrations:  bundle exec rake rom:migrate
* Add rake task to fix auto-increment sequences on existing tables
* Convert Rails migrations to Sequel format migrations
* Add rake task to mark migrations that have already applied

ROM migration:
* uses Sequel.migration do instead of class ..< ActiveRecord::Migration
* we need to declare explicitly primary_key :id
* String instead of string - DateTime, Date instead of datetime
* Adds a new sequel_schema_migrations table

related to [#403]
Update rom variable in specs

related to [#403]

Co-authored-by: Jane Sandberg <[email protected]>
christinach and others added 5 commits December 16, 2025 12:36
The issue here was that Rails tries to access rom in the config object
but we run with :autoload instead of :environment so the ROM initializer does not run and rom is not defined
with this fix we're checking first if it exists; If it doesn't
we fall back to create a rom constainer using
RomFactory.new.require_rom!

related to [#403]
Co-authored-by: Christina Chortaria <[email protected]>
@christinach
Copy link
Member Author

christinach commented Dec 17, 2025

In order to run the tests successfully please run:
RAILS_ENV=test bundle exec rake rom:migrate
and then
bundle exec rspec

to test directly the db_connection Failure and Success

related to [#403]
the fallback of the rails_rom_container in CSVLoadingService
In cases where Rails.application is nil
or Rails.application.config has not rom method
it rescues the NoMethodError  returns nil
and falls back to RomFactory.new.require_rom!

related to [#403]
table is missing
or when sequel_schema_migration exists but one
other table is  missing

related to [#403]
that rom_if_available returns failure
if database connection is not ready

related to [#403]
@pulbot pulbot requested a deployment to staging December 17, 2025 18:28 Abandoned
@christinach christinach force-pushed the 403-database-rom branch 2 times, most recently from 65c0007 to 4e0ec1a Compare December 17, 2025 21:51
…ing the rom:migrate

This is needed only for a first setup.
Otherwise the deploy errors because the tables already exist from
the previous Rails migration

related to [#403]
to old_rails_migrate

related to [#403]
on roles(:db) do
within release_path do
with rails_env: fetch(:rails_env) do
execute :bundle, :exec, :rake, 'rom:migrations_applied'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to run this rake task for a 1st time setup. I ran it on staging when I deployed with capistrano this PR.
We should keep it for when we run it in production for the first time.
After that it is safe to remove it.

@christinach
Copy link
Member Author

I renamed the migrate directory that has the Rails applications in case we need to compare something between the rails and rom migration files.
After that it is safe to remove it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants