diff options
author | James Lopez <james@jameslopez.es> | 2016-03-22 09:56:56 +0100 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-03-22 09:56:56 +0100 |
commit | 8a26f836882112657db4e616066e70722677f049 (patch) | |
tree | 85a3d408ee818a80275abe38db9a88ecd24ab2e1 /db | |
parent | e937f312cdaa4b98f6f043c6a6baa1be03868bf0 (diff) | |
parent | 383ead5d58a0553b7700aa922ad67c41b16eadf7 (diff) | |
download | gitlab-ce-8a26f836882112657db4e616066e70722677f049.tar.gz |
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into fix/project-import_url
Diffstat (limited to 'db')
6 files changed, 85 insertions, 1 deletions
diff --git a/db/migrate/20160225090018_add_delete_at_to_issues.rb b/db/migrate/20160225090018_add_delete_at_to_issues.rb new file mode 100644 index 00000000000..3ddbef92978 --- /dev/null +++ b/db/migrate/20160225090018_add_delete_at_to_issues.rb @@ -0,0 +1,6 @@ +class AddDeleteAtToIssues < ActiveRecord::Migration + def change + add_column :issues, :deleted_at, :datetime + add_index :issues, :deleted_at + end +end diff --git a/db/migrate/20160225101956_add_delete_at_to_merge_requests.rb b/db/migrate/20160225101956_add_delete_at_to_merge_requests.rb new file mode 100644 index 00000000000..9d09105f17d --- /dev/null +++ b/db/migrate/20160225101956_add_delete_at_to_merge_requests.rb @@ -0,0 +1,6 @@ +class AddDeleteAtToMergeRequests < ActiveRecord::Migration + def change + add_column :merge_requests, :deleted_at, :datetime + add_index :merge_requests, :deleted_at + end +end diff --git a/db/migrate/20160301124843_add_visibility_level_to_groups.rb b/db/migrate/20160301124843_add_visibility_level_to_groups.rb new file mode 100644 index 00000000000..d1b921bb208 --- /dev/null +++ b/db/migrate/20160301124843_add_visibility_level_to_groups.rb @@ -0,0 +1,29 @@ +class AddVisibilityLevelToGroups < ActiveRecord::Migration + def up + add_column :namespaces, :visibility_level, :integer, null: false, default: Gitlab::VisibilityLevel::PUBLIC + add_index :namespaces, :visibility_level + + # Unfortunately, this is needed on top of the `default`, since we don't want the configuration specific + # `allowed_visibility_level` to end up in schema.rb + if allowed_visibility_level < Gitlab::VisibilityLevel::PUBLIC + execute("UPDATE namespaces SET visibility_level = #{allowed_visibility_level}") + end + end + + def down + remove_column :namespaces, :visibility_level + end + + private + + def allowed_visibility_level + application_settings = select_one("SELECT restricted_visibility_levels FROM application_settings ORDER BY id DESC LIMIT 1") + if application_settings + restricted_visibility_levels = YAML.safe_load(application_settings["restricted_visibility_levels"]) rescue nil + end + restricted_visibility_levels ||= [] + + allowed_levels = Gitlab::VisibilityLevel.values - restricted_visibility_levels + allowed_levels.max + end +end diff --git a/db/migrate/20160308212903_add_default_group_visibility_to_application_settings.rb b/db/migrate/20160308212903_add_default_group_visibility_to_application_settings.rb new file mode 100644 index 00000000000..75de5f70fa2 --- /dev/null +++ b/db/migrate/20160308212903_add_default_group_visibility_to_application_settings.rb @@ -0,0 +1,29 @@ +# Create visibility level field on DB +# Sets default_visibility_level to value on settings if not restricted +# If value is restricted takes higher visibility level allowed + +class AddDefaultGroupVisibilityToApplicationSettings < ActiveRecord::Migration + def up + add_column :application_settings, :default_group_visibility, :integer + # Unfortunately, this can't be a `default`, since we don't want the configuration specific + # `allowed_visibility_level` to end up in schema.rb + execute("UPDATE application_settings SET default_group_visibility = #{allowed_visibility_level}") + end + + def down + remove_column :application_settings, :default_group_visibility + end + + private + + def allowed_visibility_level + application_settings = select_one("SELECT restricted_visibility_levels FROM application_settings ORDER BY id DESC LIMIT 1") + if application_settings + restricted_visibility_levels = YAML.safe_load(application_settings["restricted_visibility_levels"]) rescue nil + end + restricted_visibility_levels ||= [] + + allowed_levels = Gitlab::VisibilityLevel.values - restricted_visibility_levels + allowed_levels.max + end +end diff --git a/db/migrate/20160320204112_index_namespaces_on_visibility_level.rb b/db/migrate/20160320204112_index_namespaces_on_visibility_level.rb new file mode 100644 index 00000000000..370b339d45c --- /dev/null +++ b/db/migrate/20160320204112_index_namespaces_on_visibility_level.rb @@ -0,0 +1,7 @@ +class IndexNamespacesOnVisibilityLevel < ActiveRecord::Migration + def change + unless index_exists?(:namespaces, :visibility_level) + add_index :namespaces, :visibility_level + end + end +end diff --git a/db/schema.rb b/db/schema.rb index a70b2ed1f63..53d12aa35dd 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: 20160317092222) do +ActiveRecord::Schema.define(version: 20160320204112) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -77,6 +77,7 @@ ActiveRecord::Schema.define(version: 20160317092222) do t.boolean "akismet_enabled", default: false t.string "akismet_api_key" t.boolean "email_author_in_body", default: false + t.integer "default_group_visibility" end create_table "audit_events", force: :cascade do |t| @@ -418,6 +419,7 @@ ActiveRecord::Schema.define(version: 20160317092222) do t.integer "updated_by_id" t.integer "moved_to_id" t.boolean "confidential", default: false + t.datetime "deleted_at" end add_index "issues", ["assignee_id"], name: "index_issues_on_assignee_id", using: :btree @@ -425,6 +427,7 @@ ActiveRecord::Schema.define(version: 20160317092222) do add_index "issues", ["confidential"], name: "index_issues_on_confidential", using: :btree add_index "issues", ["created_at", "id"], name: "index_issues_on_created_at_and_id", using: :btree add_index "issues", ["created_at"], name: "index_issues_on_created_at", using: :btree + add_index "issues", ["deleted_at"], name: "index_issues_on_deleted_at", using: :btree add_index "issues", ["description"], name: "index_issues_on_description_trigram", using: :gin, opclasses: {"description"=>"gin_trgm_ops"} add_index "issues", ["milestone_id"], name: "index_issues_on_milestone_id", using: :btree add_index "issues", ["project_id", "iid"], name: "index_issues_on_project_id_and_iid", unique: true, using: :btree @@ -547,12 +550,14 @@ ActiveRecord::Schema.define(version: 20160317092222) do t.boolean "merge_when_build_succeeds", default: false, null: false t.integer "merge_user_id" t.string "merge_commit_sha" + t.datetime "deleted_at" end add_index "merge_requests", ["assignee_id"], name: "index_merge_requests_on_assignee_id", using: :btree add_index "merge_requests", ["author_id"], name: "index_merge_requests_on_author_id", using: :btree add_index "merge_requests", ["created_at", "id"], name: "index_merge_requests_on_created_at_and_id", using: :btree add_index "merge_requests", ["created_at"], name: "index_merge_requests_on_created_at", using: :btree + add_index "merge_requests", ["deleted_at"], name: "index_merge_requests_on_deleted_at", using: :btree add_index "merge_requests", ["description"], name: "index_merge_requests_on_description_trigram", using: :gin, opclasses: {"description"=>"gin_trgm_ops"} add_index "merge_requests", ["milestone_id"], name: "index_merge_requests_on_milestone_id", using: :btree add_index "merge_requests", ["source_branch"], name: "index_merge_requests_on_source_branch", using: :btree @@ -591,6 +596,7 @@ ActiveRecord::Schema.define(version: 20160317092222) do t.string "description", default: "", null: false t.string "avatar" t.boolean "share_with_group_lock", default: false + t.integer "visibility_level", default: 20, null: false end add_index "namespaces", ["created_at", "id"], name: "index_namespaces_on_created_at_and_id", using: :btree @@ -600,6 +606,7 @@ ActiveRecord::Schema.define(version: 20160317092222) do add_index "namespaces", ["path"], name: "index_namespaces_on_path", unique: true, using: :btree add_index "namespaces", ["path"], name: "index_namespaces_on_path_trigram", using: :gin, opclasses: {"path"=>"gin_trgm_ops"} add_index "namespaces", ["type"], name: "index_namespaces_on_type", using: :btree + add_index "namespaces", ["visibility_level"], name: "index_namespaces_on_visibility_level", using: :btree create_table "notes", force: :cascade do |t| t.text "note" |