Skip to content

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
@urkle
Copy link
Member

urkle commented Jan 13, 2025

@zverok another option is to help finish the work on this PR SchemaPlus/schema_plus_enums#17 which implements ALL of the functionality in ARPGE in schema+.

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.

2 participants