Use structure.sql instead of schema.rb
We are going to drop support for MySQL with GitLab 12.1, see https://gitlab.com/gitlab-org/gitlab-ce/issues/52442#note_175326171.
From that point on, we are only going to support PostgreSQL. The big benefit from that is that we are more free to use powerful PostgreSQL features without the need to figure out a (maybe different) way how to do this with MySQL.
Now what keeps us from using those features is the use of schema.rb
. This is can only contain standard migrations (using the Rails DSL), which aim to keep the schema file database system neutral and abstract away from specific SQL. This in turn means we are not able to use extended PostgreSQL features that are reflected in schema. Some examples include triggers, postgres partitioning, materialized views and many other great features.
In order to leverage those features, we should consider using a plain SQL schema file (structure.sql
) instead of a ruby/rails standard schema schema.rb
.
The change would entail to switch config.active_record.schema_format = :sql
and regenerate the schema in SQL. Possibly, some build steps would have to be adjusted, too.
Reads: https://edgeguides.rubyonrails.org/active_record_migrations.html#types-of-schema-dumps