diff --git a/changelogs/unreleased/disallow-null-values-for-environments-project-id.yml b/changelogs/unreleased/disallow-null-values-for-environments-project-id.yml new file mode 100644 index 0000000000000000000000000000000000000000..f4a956e67248be125117a4c2aa2478499303e3e9 --- /dev/null +++ b/changelogs/unreleased/disallow-null-values-for-environments-project-id.yml @@ -0,0 +1,5 @@ +--- +title: "Disallow NULL values for environments.project_id" +merge_request: +author: +type: other diff --git a/db/migrate/20170913131410_environments_project_id_not_null.rb b/db/migrate/20170913131410_environments_project_id_not_null.rb new file mode 100644 index 0000000000000000000000000000000000000000..d5404f8ede9989b5947537489e713b1cf517fabb --- /dev/null +++ b/db/migrate/20170913131410_environments_project_id_not_null.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 2149f5ad23df0a8d17a55115c59bf6b6403a5605..dd0ef04788b6919c91318d520371f63d89f5b1e4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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"