teoljungberg / fx

Versioned database functions and triggers for Rails
MIT License
763 stars 77 forks source link

Fix forward references when loading schema #95

Closed pjungwir closed 1 year ago

pjungwir commented 2 years ago

If your functions depend on each other, you may wind up with forward references in your schema.rb file (even though we order them by oid, e.g. if an older function was refactored to call new functions). Postgres has the same problem in pg_dump, and they solve it by temporarily disabling a GUC called check_function_bodies. This commit adds calls to schema.rb to do the same thing.

I haven't added any new tests yet (though old ones all pass), and I haven't thought about how this breaks non-Postgres adapters (if there are any out there). So this is just a quick fix I can use personally, but if you would like a more polished version please let me know if you agree with the general approach here.

teoljungberg commented 1 year ago

As we do have other adapters after going through old issues:

https://github.com/teoljungberg/fx/pull/80

Meaning, we need to have this be database-specific if we are going to go forward.

I'll close this PR until that is handled, if we are going to handle it.