diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-09-02 17:35:15 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2019-01-04 18:38:17 +0300 |
commit | 0103d5be960e620342c67436ddd64ca9e729d7a8 (patch) | |
tree | b4f2cdd4a5ef8f6c906d71c674cc5f13f791c889 /doc | |
parent | b647ad96f6e7cd1e6ca078635bb1ea49ee7d589f (diff) |
Add config_options|variables to BuildMetadata
These are data columns that store runtime configuration
of build needed to execute it on runner and within pipeline.
The definition of this data is that once used, and when no longer
needed (due to retry capability) they can be freely removed.
They use `jsonb` on PostgreSQL, and `text` on MySQL (due to lacking
support for json datatype on old enough version).
Diffstat (limited to 'doc')
-rw-r--r-- | doc/development/migration_style_guide.md | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/doc/development/migration_style_guide.md b/doc/development/migration_style_guide.md index d0a054c3290..23aa318ef91 100644 --- a/doc/development/migration_style_guide.md +++ b/doc/development/migration_style_guide.md @@ -325,6 +325,31 @@ This ensures all timestamps have a time zone specified. This in turn means exist suddenly use a different timezone when the system's timezone changes. It also makes it very clear which timezone was used in the first place. +## Storing JSON in database + +The Rails 5 natively supports `JSONB` (binary JSON) column type. +Example migration adding this column: + +```ruby +class AddOptionsToBuildMetadata < ActiveRecord::Migration[5.0] + DOWNTIME = false + + def change + add_column :ci_builds_metadata, :config_options, :jsonb + end +end +``` + +On MySQL the `JSON` and `JSONB` is translated to `TEXT 1MB`, as `JSONB` is PostgreSQL only feature. + +For above reason you have to use a serializer to provide a translation layer +in order to support PostgreSQL and MySQL seamlessly: + +```ruby +class BuildMetadata + serialize :config_options, Serializers::JSON # rubocop:disable Cop/ActiveRecordSerialize +end +``` ## Testing |