Commit 41b2d4b3 authored by Andy Soiron's avatar Andy Soiron

Add naming conventions to migration style guide

parent bafa3cbe
...@@ -114,6 +114,18 @@ rails schema statement: [`add_index`](https://api.rubyonrails.org/v5.2/classes/A ...@@ -114,6 +114,18 @@ rails schema statement: [`add_index`](https://api.rubyonrails.org/v5.2/classes/A
This is a blocking operation, but it doesn't cause problems because the table is not yet used, This is a blocking operation, but it doesn't cause problems because the table is not yet used,
and therefore it does not have any records yet. and therefore it does not have any records yet.
## Naming conventions
We keep column names consistent with [ActiveRecord's schema conventions](https://guides.rubyonrails.org/active_record_basics.html#schema-conventions).
Custom index names should follow the pattern `index_#{table_name}_on_#{column_1}_and_#{column_2}_#{condition}`.
Examples:
- `index_services_on_type_and_id_and_template_when_active`
- `index_projects_on_id_service_desk_enabled`
- `index_clusters_on_enabled_cluster_type_id_and_created_at`
## Heavy operations in a single transaction ## Heavy operations in a single transaction
When using a single-transaction migration, a transaction holds a database connection When using a single-transaction migration, a transaction holds a database connection
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment