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

Resolve conflict with other schema dumpers #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zverok
Copy link

@zverok zverok commented Dec 15, 2024

After switching to SchemaDumper 3.1.0, we have a conflict with activerecord-postgres_enum SchemaDumper (code).

The nature is this: ARPGE redefines SchemaDumper#tables method, but it doesn’t further call methods like table (which SchemaPlus redefines) and rather writes its statements create_enum directly into stream.

This causes one of two problems:

  • If ARPGE is lower than schema_plus_core in Gemfile (=its redefinition of table happens earlier than ours), it manages to write to file directly, leading to create_enum statements being higher in the file than ActiveRecord::Schema.define (which is postponed by Schema+ dumper). Solved by adjustment of #dump method.
  • If ARPGE is higher than schema_plus_core (=its redefinition of table happens later and nested in ours), it fails with NoMethodError due to nil passed instead of the stream it tries to write to. Solved by adjustment of #tables methods.

Two things to note:

  1. Solutions are kinda naive. Everything that is written beside the main flow is considered part of the “header”. Works with activerecord-postgres_enum, might be broken with some other schema dumpers.
  2. I am not sure how to write specs for this. Please advise 🙏

@zverok zverok force-pushed the other-schema-dumpers branch from ec12107 to 8ab52b7 Compare December 15, 2024 07:55
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.

1 participant