Use structure.sql instead of schema.rb (#29465) · Issues · GitLab.org / GitLab · GitLab (original) (raw)

Skip to content

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

This page may contain information related to upcoming products, features and functionality. It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes. Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.

Edited May 30, 2022 by 🤖 GitLab Bot 🤖