Allow no-monkeypatching extension of schema.rb builder

Per issues like #36921 and projects like https://github.com/SchemaPlus/schema_plus_enums, it seems like a lot of folks want to use Postgres custom types in Rails without having to resort to structure.sql. (structure.sql support has gotten a lot better, but it’s still vulnerable to e.g. nonsense churn caused by folks running different DB versions locally.)

Other Postgres-specific features, such as foreign data wrappers, are near-unusable within Rails when you’re committing your schema – schema.rb ignores them, and structure.sql encodes information that should never be committed, like database passwords.

I don’t think that Rails, as a project, should necessarily be in the business of maintaining schema.rb dumpers for a lot of different, esoteric database-specific features. But right now, if you want to extend schema.rb’s functionality, you need to monkeypatch Rails internals. That makes extensions fragile when upgrading, and discourages both potential and actual gem authors from sticking with their gems for the long haul.

I’d like there to be a stable, external-facing interface allowing folks to extend schema.rb dumpers with database-specific features, without monkeypatching. I’m happy to take on the work of implementing this.

1 Like