From badb9c1deacbea601b02f88811b7e123589d9251 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 17 Dec 2019 12:08:11 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- lib/gitlab/database/migration_helpers.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/gitlab/database') diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb index 03bde611451..f9340b262e5 100644 --- a/lib/gitlab/database/migration_helpers.rb +++ b/lib/gitlab/database/migration_helpers.rb @@ -1052,6 +1052,15 @@ into similar problems in the future (e.g. when new tables are created). connection.select_value(index_sql).to_i > 0 end + def create_or_update_plan_limit(limit_name, plan_name, limit_value) + execute <<~SQL + INSERT INTO plan_limits (plan_id, #{quote_column_name(limit_name)}) + VALUES + ((SELECT id FROM plans WHERE name = #{quote(plan_name)} LIMIT 1), #{quote(limit_value)}) + ON CONFLICT (plan_id) DO UPDATE SET #{quote_column_name(limit_name)} = EXCLUDED.#{quote_column_name(limit_name)}; + SQL + end + private def tables_match?(target_table, foreign_key_table) -- cgit v1.2.1