summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2019-01-06 09:47:29 +0000
committerGrzegorz Bizon <grzegorz@gitlab.com>2019-01-06 09:47:29 +0000
commit1aa2ac13b95b9fa9527596610bb07e132dc1a6f0 (patch)
treea04dba27d51620b49b93e2d25a8ed6222cefa914 /config
parent52d0c0edb796f21498fb4b88c99ffa6020c048a9 (diff)
parent0103d5be960e620342c67436ddd64ca9e729d7a8 (diff)
downloadgitlab-ce-1aa2ac13b95b9fa9527596610bb07e132dc1a6f0.tar.gz
Merge branch 'kamil-refactor-ci-builds-v5' into 'master'
Use BuildMetadata to store build configuration in JSONB form See merge request gitlab-org/gitlab-ce!21499
Diffstat (limited to 'config')
-rw-r--r--config/initializers/ar_mysql_jsonb_support.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/config/initializers/ar_mysql_jsonb_support.rb b/config/initializers/ar_mysql_jsonb_support.rb
new file mode 100644
index 00000000000..63a0b05119a
--- /dev/null
+++ b/config/initializers/ar_mysql_jsonb_support.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+require 'active_record/connection_adapters/abstract_mysql_adapter'
+require 'active_record/connection_adapters/mysql/schema_definitions'
+
+# MySQL (5.6) and MariaDB (10.1) are currently supported versions within GitLab,
+# Since they do not support native `json` datatype we force to emulate it as `text`
+
+if Gitlab::Database.mysql?
+ module ActiveRecord
+ module ConnectionAdapters
+ class AbstractMysqlAdapter
+ JSON_DATASIZE = 1.megabyte
+
+ NATIVE_DATABASE_TYPES.merge!(
+ json: { name: "text", limit: JSON_DATASIZE },
+ jsonb: { name: "text", limit: JSON_DATASIZE }
+ )
+ end
+
+ module MySQL
+ module ColumnMethods
+ # We add `jsonb` helper, as `json` is already defined for `MySQL` since Rails 5
+ def jsonb(*args, **options)
+ args.each { |name| column(name, :json, options) }
+ end
+ end
+ end
+ end
+ end
+end