summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorFelipe Artur <felipefac@gmail.com>2018-02-19 16:06:16 -0300
committerFelipe Artur <felipefac@gmail.com>2018-03-03 12:56:17 -0300
commitdd071c4b6e9754a0abeec45ab2040d9e2d5a62b8 (patch)
tree9dda99bb987378cb6cbc95d236757d11f21176a6 /db
parent98fecb5f8e64c4c64c96d065bc342d986140367e (diff)
downloadgitlab-ce-dd071c4b6e9754a0abeec45ab2040d9e2d5a62b8.tar.gz
Bring one group board to CE
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20180227182112_add_group_id_to_boards.rb39
-rw-r--r--db/schema.rb5
2 files changed, 43 insertions, 1 deletions
diff --git a/db/migrate/20180227182112_add_group_id_to_boards.rb b/db/migrate/20180227182112_add_group_id_to_boards.rb
new file mode 100644
index 00000000000..d5da85bebcd
--- /dev/null
+++ b/db/migrate/20180227182112_add_group_id_to_boards.rb
@@ -0,0 +1,39 @@
+# This is part of a backport from EE group boards feature which a few extra steps
+# are required on this migration since it will be merged into EE which already
+# contains the group_id column.
+# like checking if the group_id column already exists before adding it.
+
+class AddGroupIdToBoards < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ DOWNTIME = false
+
+ def up
+ unless group_id_exists?
+ add_column :boards, :group_id, :integer
+ add_foreign_key :boards, :namespaces, column: :group_id, on_delete: :cascade
+ add_concurrent_index :boards, :group_id
+
+ change_column_null :boards, :project_id, true
+ end
+ end
+
+ def down
+ if group_id_exists?
+ remove_foreign_key :boards, column: :group_id
+ remove_index :boards, :group_id if index_exists? :boards, :group_id
+ remove_column :boards, :group_id
+
+ execute "DELETE from boards WHERE project_id IS NULL"
+ change_column_null :boards, :project_id, false
+ end
+ end
+
+ private
+
+ def group_id_exists?
+ column_exists?(:boards, :group_id)
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index db8bafe9677..1f68ad72308 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -184,11 +184,13 @@ ActiveRecord::Schema.define(version: 20180301084653) do
add_index "award_emoji", ["user_id", "name"], name: "index_award_emoji_on_user_id_and_name", using: :btree
create_table "boards", force: :cascade do |t|
- t.integer "project_id", null: false
+ t.integer "project_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
+ t.integer "group_id"
end
+ add_index "boards", ["group_id"], name: "index_boards_on_group_id", using: :btree
add_index "boards", ["project_id"], name: "index_boards_on_project_id", using: :btree
create_table "broadcast_messages", force: :cascade do |t|
@@ -1969,6 +1971,7 @@ ActiveRecord::Schema.define(version: 20180301084653) do
add_index "web_hooks", ["project_id"], name: "index_web_hooks_on_project_id", using: :btree
add_index "web_hooks", ["type"], name: "index_web_hooks_on_type", using: :btree
+ add_foreign_key "boards", "namespaces", column: "group_id", on_delete: :cascade
add_foreign_key "boards", "projects", name: "fk_f15266b5f9", on_delete: :cascade
add_foreign_key "chat_teams", "namespaces", on_delete: :cascade
add_foreign_key "ci_build_trace_section_names", "projects", on_delete: :cascade