diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-09-28 15:34:09 +0200 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-10-07 11:46:22 +0200 |
commit | 20727db1702849b78e6714197f16f602f68cecf8 (patch) | |
tree | 7b5a642c233833ef92cef9df1405c704b646f4a3 /db | |
parent | 8eec69ef41ed66c2ef3c5db73f97eb39a9458f72 (diff) | |
download | gitlab-ce-20727db1702849b78e6714197f16f602f68cecf8.tar.gz |
Add a model for `fork_networks`
The fork network will keep track of the root project as long as it's
present.
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20170928124105_create_fork_networks.rb | 28 | ||||
-rw-r--r-- | db/schema.rb | 8 |
2 files changed, 36 insertions, 0 deletions
diff --git a/db/migrate/20170928124105_create_fork_networks.rb b/db/migrate/20170928124105_create_fork_networks.rb new file mode 100644 index 00000000000..ca906b953a3 --- /dev/null +++ b/db/migrate/20170928124105_create_fork_networks.rb @@ -0,0 +1,28 @@ +class CreateForkNetworks < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + create_table :fork_networks do |t| + t.references :root_project, + references: :projects, + index: { unique: true } + + t.string :deleted_root_project_name + end + + add_concurrent_foreign_key :fork_networks, :projects, + column: :root_project_id, + on_delete: :nullify + end + + def down + if foreign_keys_for(:fork_networks, :root_project_id).any? + remove_foreign_key :fork_networks, column: :root_project_id + end + drop_table :fork_networks + end +end diff --git a/db/schema.rb b/db/schema.rb index 25aa15b837f..d7e1a2c94fa 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -591,6 +591,13 @@ ActiveRecord::Schema.define(version: 20171006091000) do add_index "features", ["key"], name: "index_features_on_key", unique: true, using: :btree + create_table "fork_networks", force: :cascade do |t| + t.integer "root_project_id" + t.string "deleted_root_project_name" + end + + add_index "fork_networks", ["root_project_id"], name: "index_fork_networks_on_root_project_id", unique: true, using: :btree + create_table "forked_project_links", force: :cascade do |t| t.integer "forked_to_project_id", null: false t.integer "forked_from_project_id", null: false @@ -1793,6 +1800,7 @@ ActiveRecord::Schema.define(version: 20171006091000) do add_foreign_key "environments", "projects", name: "fk_d1c8c1da6a", on_delete: :cascade add_foreign_key "events", "projects", on_delete: :cascade add_foreign_key "events", "users", column: "author_id", name: "fk_edfd187b6f", on_delete: :cascade + add_foreign_key "fork_networks", "projects", column: "root_project_id", name: "fk_e7b436b2b5", on_delete: :nullify add_foreign_key "forked_project_links", "projects", column: "forked_to_project_id", name: "fk_434510edb0", on_delete: :cascade add_foreign_key "gcp_clusters", "projects", on_delete: :cascade add_foreign_key "gcp_clusters", "services", on_delete: :nullify |