From d9abaab0c8fcc2f09c525a75093f7bb8858764ad Mon Sep 17 00:00:00 2001 From: Arun Kumar Mohan Date: Tue, 18 Jun 2019 17:14:33 -0500 Subject: Disallow `NULL` values for `geo_nodes.primary` column --- .../20190618171120_update_geo_nodes_primary.rb | 20 ++++++++++++++++++++ db/schema.rb | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 db/post_migrate/20190618171120_update_geo_nodes_primary.rb diff --git a/db/post_migrate/20190618171120_update_geo_nodes_primary.rb b/db/post_migrate/20190618171120_update_geo_nodes_primary.rb new file mode 100644 index 00000000000..dc9cfbda177 --- /dev/null +++ b/db/post_migrate/20190618171120_update_geo_nodes_primary.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class UpdateGeoNodesPrimary < ActiveRecord::Migration[5.1] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def up + change_column_default(:geo_nodes, :primary, false) + change_column_null(:geo_nodes, :primary, false, false) + end + + def down + change_column_default(:geo_nodes, :primary, nil) + change_column_null(:geo_nodes, :primary, true) + end +end diff --git a/db/schema.rb b/db/schema.rb index a9643d70966..5d48aa5087d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20190613030606) do +ActiveRecord::Schema.define(version: 20190618171120) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -1391,7 +1391,7 @@ ActiveRecord::Schema.define(version: 20190613030606) do end create_table "geo_nodes", id: :serial, force: :cascade do |t| - t.boolean "primary" + t.boolean "primary", default: false, null: false t.integer "oauth_application_id" t.boolean "enabled", default: true, null: false t.string "access_key" -- cgit v1.2.1 From a10d80eaddf81eb4996df586cc1e871f1e8b0779 Mon Sep 17 00:00:00 2001 From: Arun Kumar Mohan Date: Tue, 18 Jun 2019 17:16:33 -0500 Subject: Add changelog entry --- changelogs/unreleased/db-update-geo-nodes-primary.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelogs/unreleased/db-update-geo-nodes-primary.yml diff --git a/changelogs/unreleased/db-update-geo-nodes-primary.yml b/changelogs/unreleased/db-update-geo-nodes-primary.yml new file mode 100644 index 00000000000..7c5203353ac --- /dev/null +++ b/changelogs/unreleased/db-update-geo-nodes-primary.yml @@ -0,0 +1,5 @@ +--- +title: Disallow `NULL` values for `geo_nodes.primary` column +merge_request: 29818 +author: Arun Kumar Mohan +type: other -- cgit v1.2.1