rails / solid_queue

Database-backed Active Job backend
MIT License
1.95k stars 130 forks source link

`queue_schema.rb` dissapears after `rails db:migrate:reset` #384

Closed konradperlowski closed 3 weeks ago

konradperlowski commented 1 month ago

Hi, I added solid queue configuration for my development environment and after running rails db:migrate:reset command (or manually running db:drop db:create db:migrate) file queue_schema.rb is empty.

I have following configurations:

When I run db:drop and then db:prepare it works fine.

rosa commented 1 month ago

Hey @konradperlowski, I think it might be due to this bug in Rails https://github.com/rails/rails/issues/52829. It's already been fixed, but perhaps you're on a previous version.

konradperlowski commented 1 month ago

I tried this on rails 7.2.1 and 8.0.0.beta1 and it cleared queue_schema.rb file

rosa commented 1 month ago

I think that change might not have been released in any of those. Could you try Rails edge instead?

konradperlowski commented 1 month ago

It still happens on edge, but it works correctly with sqllite (not sure about previous rails versions) - it does not work with psql

rosa commented 1 month ago

Huh, that's really strange. This shouldn't depend on the DBMS you're using. Maybe add a comment to that original Rails issue?

konradperlowski commented 1 month ago

No, my bad - it does not work with sqlite :sweat_smile:

danielschnee commented 1 month ago

Hey @konradperlowski, do you still have solid_queue migrations in db/migrate?

I had the same. Deleted all the solid_queue migrations and then run the commands and now i only get some formatting but the content stays in queue_schema.rb

konradperlowski commented 1 month ago

Hey @konradperlowski, do you still have solid_queue migrations in db/migrate?

I had the same. Deleted all the solid_queue migrations and then run the commands and now i only get some formatting but the content stays in queue_schema.rb

No, I don't have any solid queue related migrations in db/migrate. I believe this pr will fix this issue, so I wait for this to be merged into rails main, then I will test this again and hopefully close this issue

jherdman commented 3 weeks ago

FYI this still problem still exists on Rails 8.0.0@fa35b70a5f6863104856f25641026fc4d449b449

konradperlowski commented 3 weeks ago

Using current rails main (after merging this pr) I cannot reproduce this issue anymore

Kagayakashi commented 1 week ago

The problem still exists with Ruby 3.3.4, Rails 8.0.0, and solid_queue 1.0.1 after running the command bin/rails db:migrate:reset.

Am I missing something, or is it supposed to work this way?

Also, I’m wondering why this gem doesn’t use migrations, as other gems typically do with generators or install tasks. Would using migrations help prevent issues like this? Shouldn't the database schema be generated based on migrations? Why is a pre-defined schema being used instead?