36 lines
913 B
Ruby
36 lines
913 B
Ruby
# == Schema Information
|
|
#
|
|
# Table name: sync_repositories
|
|
#
|
|
# id :integer not null, primary key
|
|
# project_id :integer
|
|
# type :string(255)
|
|
# repo_name :string(255)
|
|
# external_repo_address :string(255)
|
|
# sync_granularity :integer
|
|
# sync_direction :integer
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
# external_token :string(255)
|
|
# webhook_gid :integer
|
|
#
|
|
# Indexes
|
|
#
|
|
# index_sync_repositories_on_project_id (project_id)
|
|
#
|
|
|
|
class SyncRepository < ApplicationRecord
|
|
|
|
belongs_to :project
|
|
has_many :sync_repository_branches, dependent: :destroy
|
|
|
|
before_destroy :unbind_reposyncer
|
|
|
|
validates :repo_name, uniqueness: { message: "已存在" }
|
|
|
|
def unbind_reposyncer
|
|
Reposync::DeleteRepoService.call(self.repo_name) rescue nil
|
|
end
|
|
|
|
end
|