Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for trigger ordering to be alphabetical #250

Closed
bschrag620 opened this issue Oct 3, 2024 · 0 comments · Fixed by #251
Closed

Allow for trigger ordering to be alphabetical #250

bschrag620 opened this issue Oct 3, 2024 · 0 comments · Fixed by #251

Comments

@bschrag620
Copy link
Contributor

Tell us about your environment

Ruby Version: 3.0

Rails Version: 7.1

PostgreSQL Version: 14.?

Logidze Version: 1.2.1 though this exists on 1.3.0

What did you do?

We use some CI tooling to ensure non-related schema changes are not being made during a pull request. This is done by checking out the commit off which a branch was based on main, the running rails db:prepare, then resetting using git reset --hard, then finally rails db:migrate and checking for any diffs. If diffs exist then we know changes made their way into the schema file that aren't applicable to the pull request being submitted.

This becomes difficult (perhaps more annoying than difficult) to manage with Logdize because the create_triggers are ordered by our local dev machines based on the id/age of the table for which the trigger belongs to. When running rails db:prepare, table age/ids match the alphabetical order of the tables since schema.rb is read top-to-bottom. This leads to a diff occurring in our CI process because in the local environment, the trigger position in schema.rb may not (and most likely won't) match alphabetical order.

To fully replicate, start with a new (or existing) rails app:

  1. Create a model Zzz using a generator - run the migrations
  2. Add logdize to the Zzz model via the generator - run the migrations
  3. Create a model Aaa using a generator - run the migrations
  4. Add logdize to the Aaa model via the generator - run the migrations
  5. Note that at this point, schema.rb will show create_trigger on aaa is coming after the create_trigger for zzz
  6. Commit these changes
  7. Then run rails db:drop && rails db:prepare
  8. Note that there are now changes compared to the previous commit

What did you expect to happen?

It would be nice to be able to configure the create_triggers dump to keep the triggers in alphabetical order.

What actually happened?

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 a pull request may close this issue.

1 participant