Commit 72014170 authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg

Drop NULL constraint on Geo event columns

The columns effected store the repository storage path, which can't be
NULL. So in general the path can't be NULL. However, the tables also
include the shard name. From the shard name, the storage path can be
determined, allowing for a more dynamic approach.
parent e2529196
...@@ -1020,7 +1020,7 @@ ActiveRecord::Schema.define(version: 20180419031622) do ...@@ -1020,7 +1020,7 @@ ActiveRecord::Schema.define(version: 20180419031622) do
create_table "geo_hashed_storage_migrated_events", id: :bigserial, force: :cascade do |t| create_table "geo_hashed_storage_migrated_events", id: :bigserial, force: :cascade do |t|
t.integer "project_id", null: false t.integer "project_id", null: false
t.text "repository_storage_name", null: false t.text "repository_storage_name", null: false
t.text "repository_storage_path", null: false t.text "repository_storage_path"
t.text "old_disk_path", null: false t.text "old_disk_path", null: false
t.text "new_disk_path", null: false t.text "new_disk_path", null: false
t.text "old_wiki_disk_path", null: false t.text "old_wiki_disk_path", null: false
...@@ -1126,7 +1126,7 @@ ActiveRecord::Schema.define(version: 20180419031622) do ...@@ -1126,7 +1126,7 @@ ActiveRecord::Schema.define(version: 20180419031622) do
create_table "geo_repository_created_events", id: :bigserial, force: :cascade do |t| create_table "geo_repository_created_events", id: :bigserial, force: :cascade do |t|
t.integer "project_id", null: false t.integer "project_id", null: false
t.text "repository_storage_name", null: false t.text "repository_storage_name", null: false
t.text "repository_storage_path", null: false t.text "repository_storage_path"
t.text "repo_path", null: false t.text "repo_path", null: false
t.text "wiki_path" t.text "wiki_path"
t.text "project_name", null: false t.text "project_name", null: false
...@@ -1137,7 +1137,7 @@ ActiveRecord::Schema.define(version: 20180419031622) do ...@@ -1137,7 +1137,7 @@ ActiveRecord::Schema.define(version: 20180419031622) do
create_table "geo_repository_deleted_events", id: :bigserial, force: :cascade do |t| create_table "geo_repository_deleted_events", id: :bigserial, force: :cascade do |t|
t.integer "project_id", null: false t.integer "project_id", null: false
t.text "repository_storage_name", null: false t.text "repository_storage_name", null: false
t.text "repository_storage_path", null: false t.text "repository_storage_path"
t.text "deleted_path", null: false t.text "deleted_path", null: false
t.text "deleted_wiki_path" t.text "deleted_wiki_path"
t.text "deleted_project_name", null: false t.text "deleted_project_name", null: false
...@@ -1148,7 +1148,7 @@ ActiveRecord::Schema.define(version: 20180419031622) do ...@@ -1148,7 +1148,7 @@ ActiveRecord::Schema.define(version: 20180419031622) do
create_table "geo_repository_renamed_events", id: :bigserial, force: :cascade do |t| create_table "geo_repository_renamed_events", id: :bigserial, force: :cascade do |t|
t.integer "project_id", null: false t.integer "project_id", null: false
t.text "repository_storage_name", null: false t.text "repository_storage_name", null: false
t.text "repository_storage_path", null: false t.text "repository_storage_path"
t.text "old_path_with_namespace", null: false t.text "old_path_with_namespace", null: false
t.text "new_path_with_namespace", null: false t.text "new_path_with_namespace", null: false
t.text "old_wiki_path_with_namespace", null: false t.text "old_wiki_path_with_namespace", null: false
......
class DropNullConstraintGeoEventsStoragePath < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
TABLES = %i(geo_hashed_storage_migrated_events geo_repository_created_events
geo_repository_deleted_events geo_repository_renamed_events)
def up
TABLES.each do |table|
change_column_null(table, :repository_storage_path, true)
end
end
def down
TABLES.each do |table|
change_column_null(table, :repository_storage_path, false)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment