Disallow NULL values for environments.project_id

This commit is contained in:
Yorick Peterse 2017-09-13 15:16:24 +02:00
parent f04094a4f8
commit 9230caa907
No known key found for this signature in database
GPG Key ID: EDD30D2BEB691AC9
3 changed files with 23 additions and 2 deletions

View File

@ -0,0 +1,5 @@
---
title: "Disallow NULL values for environments.project_id"
merge_request:
author:
type: other

View File

@ -0,0 +1,16 @@
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class EnvironmentsProjectIdNotNull < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
change_column_null :environments, :project_id, false
end
def down
change_column_null :environments, :project_id, true
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170905112933) do
ActiveRecord::Schema.define(version: 20170913131410) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -520,7 +520,7 @@ ActiveRecord::Schema.define(version: 20170905112933) do
add_index "emails", ["user_id"], name: "index_emails_on_user_id", using: :btree
create_table "environments", force: :cascade do |t|
t.integer "project_id"
t.integer "project_id", null: false
t.string "name", null: false
t.datetime "created_at"
t.datetime "updated_at"