Commit d6c66fd6 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Add a model for `fork_networks`

The fork network will keep track of the root project as long as it's
present.
parent 1d5b5df0
class ForkNetwork < ActiveRecord::Base
belongs_to :root_project
end
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
......@@ -642,6 +642,13 @@ ActiveRecord::Schema.define(version: 20171002105019) 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
......@@ -2098,6 +2105,7 @@ ActiveRecord::Schema.define(version: 20171002105019) 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 "geo_event_log", "geo_repositories_changed_events", column: "repositories_changed_event_id", name: "fk_4a99ebfd60", on_delete: :cascade
add_foreign_key "geo_event_log", "geo_repository_created_events", column: "repository_created_event_id", name: "fk_9b9afb1916", on_delete: :cascade
......
......@@ -293,6 +293,9 @@ project:
- source_pipelines
- sourced_pipelines
- members_and_requesters
- root_of_fork_network
- fork_network_member
- fork_network
award_emoji:
- awardable
- user
......
require 'rails_helper'
RSpec.describe ForkNetwork, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
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