Add Geo::RenamedEvent

parent 251fa4c1
...@@ -9,5 +9,9 @@ module Geo ...@@ -9,5 +9,9 @@ module Geo
belongs_to :repository_deleted_event, belongs_to :repository_deleted_event,
class_name: 'Geo::RepositoryDeletedEvent', class_name: 'Geo::RepositoryDeletedEvent',
foreign_key: :repository_deleted_event_id foreign_key: :repository_deleted_event_id
belongs_to :repository_renamed_event,
class_name: 'Geo::RepositoryRenamedEvent',
foreign_key: :repository_renamed_event_id
end end
end end
module Geo
class RepositoryRenamedEvent < ActiveRecord::Base
include Geo::Model
belongs_to :project
validates :project, :repository_storage_name, :repository_storage_path,
:old_path_with_namespace, :new_path_with_namespace,
:old_wiki_path_with_namespace, :new_wiki_path_with_namespace,
:old_project_name, :new_project_name, presence: true
end
end
class CreateGeoRepositoryRenamedEvents < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def change
create_table :geo_repository_renamed_events, id: :bigserial do |t|
t.references :project, index: true, foreign_key: { on_delete: :cascade }, null: false
t.text :repository_storage_name, null: false
t.text :repository_storage_path, null: false
t.text :old_path_with_namespace, null: false
t.text :new_path_with_namespace, null: false
t.text :old_wiki_path_with_namespace, null: false
t.text :new_wiki_path_with_namespace, null: false
t.text :old_project_name, null: false
t.text :new_project_name, null: false
end
add_column :geo_event_log, :repository_renamed_event_id, :integer, limit: 8
end
end
...@@ -625,6 +625,20 @@ ActiveRecord::Schema.define(version: 20170627211700) do ...@@ -625,6 +625,20 @@ ActiveRecord::Schema.define(version: 20170627211700) do
add_index "geo_repository_deleted_events", ["project_id"], name: "index_geo_repository_deleted_events_on_project_id", using: :btree add_index "geo_repository_deleted_events", ["project_id"], name: "index_geo_repository_deleted_events_on_project_id", using: :btree
create_table "geo_repository_renamed_events", id: :bigserial, force: :cascade do |t|
t.integer "project_id", null: false
t.text "repository_storage_name", null: false
t.text "repository_storage_path", null: false
t.text "old_path_with_namespace", null: false
t.text "new_path_with_namespace", null: false
t.text "old_wiki_path_with_namespace", null: false
t.text "new_wiki_path_with_namespace", null: false
t.text "old_project_name", null: false
t.text "new_project_name", null: false
end
add_index "geo_repository_renamed_events", ["project_id"], name: "index_geo_repository_renamed_events_on_project_id", using: :btree
create_table "geo_repository_updated_events", id: :bigserial, force: :cascade do |t| create_table "geo_repository_updated_events", id: :bigserial, force: :cascade do |t|
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.integer "branches_affected", null: false t.integer "branches_affected", null: false
...@@ -1863,6 +1877,7 @@ ActiveRecord::Schema.define(version: 20170627211700) do ...@@ -1863,6 +1877,7 @@ ActiveRecord::Schema.define(version: 20170627211700) do
add_foreign_key "forked_project_links", "projects", column: "forked_to_project_id", name: "fk_434510edb0", on_delete: :cascade 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_repository_deleted_events", column: "repository_deleted_event_id", name: "fk_c4b1c1f66e", on_delete: :cascade add_foreign_key "geo_event_log", "geo_repository_deleted_events", column: "repository_deleted_event_id", name: "fk_c4b1c1f66e", on_delete: :cascade
add_foreign_key "geo_event_log", "geo_repository_updated_events", column: "repository_updated_event_id", on_delete: :cascade add_foreign_key "geo_event_log", "geo_repository_updated_events", column: "repository_updated_event_id", on_delete: :cascade
add_foreign_key "geo_repository_renamed_events", "projects", on_delete: :cascade
add_foreign_key "geo_repository_updated_events", "projects", on_delete: :cascade add_foreign_key "geo_repository_updated_events", "projects", on_delete: :cascade
add_foreign_key "index_statuses", "projects", name: "fk_74b2492545", on_delete: :cascade add_foreign_key "index_statuses", "projects", name: "fk_74b2492545", on_delete: :cascade
add_foreign_key "issue_assignees", "issues", name: "fk_b7d881734a", on_delete: :cascade add_foreign_key "issue_assignees", "issues", name: "fk_b7d881734a", on_delete: :cascade
......
...@@ -3,5 +3,6 @@ require 'spec_helper' ...@@ -3,5 +3,6 @@ require 'spec_helper'
RSpec.describe Geo::EventLog, type: :model do RSpec.describe Geo::EventLog, type: :model do
describe 'relationships' do describe 'relationships' do
it { is_expected.to belong_to(:repository_updated_event).class_name('Geo::RepositoryUpdatedEvent').with_foreign_key('repository_updated_event_id') } it { is_expected.to belong_to(:repository_updated_event).class_name('Geo::RepositoryUpdatedEvent').with_foreign_key('repository_updated_event_id') }
it { is_expected.to belong_to(:repository_renamed_event).class_name('Geo::RepositoryRenamedEvent').with_foreign_key('repository_renamed_event_id') }
end end
end end
require 'spec_helper'
RSpec.describe Geo::RepositoryRenamedEvent, type: :model do
describe 'relationships' do
it { is_expected.to belong_to(:project) }
end
describe 'validations' do
it { is_expected.to validate_presence_of(:project) }
it { is_expected.to validate_presence_of(:repository_storage_name) }
it { is_expected.to validate_presence_of(:repository_storage_path) }
it { is_expected.to validate_presence_of(:old_path_with_namespace) }
it { is_expected.to validate_presence_of(:new_path_with_namespace) }
it { is_expected.to validate_presence_of(:old_wiki_path_with_namespace) }
it { is_expected.to validate_presence_of(:new_wiki_path_with_namespace) }
it { is_expected.to validate_presence_of(:old_project_name) }
it { is_expected.to validate_presence_of(:new_project_name) }
end
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