Commit 0b022b50 authored by Felipe's avatar Felipe

Fix migrations

parent 7733e8c3
Pipeline #11775674 passed with stages
in 86 minutes and 43 seconds
class ChangeProjectIdToNotNullInProjectFeatures < ActiveRecord::Migration
DOWNTIME = false
def up
# Deletes corrupted project features
delete_project_features_sql = "DELETE FROM project_features WHERE project_id IS NULL"
execute(delete_project_features_sql)
change_column_null :project_features, :project_id, false
end
def down
change_column_null :project_features, :project_id, true
end
end
......@@ -2,6 +2,10 @@ class FixProjectsWithoutProjectFeature < ActiveRecord::Migration
DOWNTIME = false
def up
# Deletes corrupted project features
sql = "DELETE FROM project_features WHERE project_id IS NULL"
execute(sql)
# Creates missing project features with private visibility
sql =
%Q{
......@@ -16,7 +20,7 @@ class FixProjectsWithoutProjectFeature < ActiveRecord::Migration
10 as snippets_access_level,
projects.created_at,
projects.updated_at
FROM "projects"
FROM projects
LEFT OUTER JOIN project_features ON project_features.project_id = projects.id
WHERE (project_features.id IS NULL)
}
......
......@@ -1113,7 +1113,7 @@ ActiveRecord::Schema.define(version: 20170913180600) do
add_index "project_authorizations", ["user_id", "project_id", "access_level"], name: "index_project_authorizations_on_user_id_project_id_access_level", unique: true, using: :btree
create_table "project_features", force: :cascade do |t|
t.integer "project_id", null: false
t.integer "project_id"
t.integer "merge_requests_access_level"
t.integer "issues_access_level"
t.integer "wiki_access_level"
......
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