refactor(documents): rename document tree model
This commit is contained in:
@@ -11,7 +11,7 @@ const (
|
||||
DocumentKindFile = "file"
|
||||
)
|
||||
|
||||
type SaDocument struct {
|
||||
type SaDocumentTree struct {
|
||||
ID uint `gorm:"primaryKey"`
|
||||
Identity string `gorm:"type:char(36);uniqueIndex"`
|
||||
ProjectID uint `gorm:"index;not null;uniqueIndex:uidx_sa_document_sibling,priority:1"`
|
||||
@@ -37,6 +37,6 @@ type SaDocument struct {
|
||||
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||
}
|
||||
|
||||
func (SaDocument) TableName() string {
|
||||
func (SaDocumentTree) TableName() string {
|
||||
return "sa_documents"
|
||||
}
|
||||
@@ -75,7 +75,7 @@ func (m *SaTask) BeforeCreate(tx *gorm.DB) error {
|
||||
return resolveOptionalIdentity(tx, &SaInboxItem{}, m.SourceInboxItemID, &m.SourceInboxItemIdentity)
|
||||
}
|
||||
|
||||
func (m *SaDocument) BeforeCreate(tx *gorm.DB) error {
|
||||
func (m *SaDocumentTree) BeforeCreate(tx *gorm.DB) error {
|
||||
if err := ensureIdentity(&m.Identity); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -85,7 +85,7 @@ func (m *SaDocument) BeforeCreate(tx *gorm.DB) error {
|
||||
if err := resolveIdentity(tx, &SaUser{}, m.CreatedBy, &m.CreatedByIdentity); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := resolveOptionalIdentity(tx, &SaDocument{}, m.ParentID, &m.ParentIdentity); err != nil {
|
||||
if err := resolveOptionalIdentity(tx, &SaDocumentTree{}, m.ParentID, &m.ParentIdentity); err != nil {
|
||||
return err
|
||||
}
|
||||
return resolveOptionalIdentity(tx, &SaInboxItem{}, m.SourceInboxItemID, &m.SourceInboxItemIdentity)
|
||||
@@ -95,7 +95,7 @@ func (m *SaDocumentShare) BeforeCreate(tx *gorm.DB) error {
|
||||
if err := ensureIdentity(&m.Identity); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := resolveIdentity(tx, &SaDocument{}, m.DocumentID, &m.DocumentIdentity); err != nil {
|
||||
if err := resolveIdentity(tx, &SaDocumentTree{}, m.DocumentID, &m.DocumentIdentity); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@@ -234,7 +234,7 @@ func resolveEntityIdentity(tx *gorm.DB, entityType string, entityID uint, identi
|
||||
case "task":
|
||||
return resolveIdentity(tx, &SaTask{}, entityID, identity)
|
||||
case "document":
|
||||
return resolveIdentity(tx, &SaDocument{}, entityID, identity)
|
||||
return resolveIdentity(tx, &SaDocumentTree{}, entityID, identity)
|
||||
case "ai_session":
|
||||
return resolveIdentity(tx, &SaAISession{}, entityID, identity)
|
||||
case "tag":
|
||||
|
||||
@@ -36,7 +36,7 @@ func AutoMigrate(database *gorm.DB) error {
|
||||
&SaInboxItem{},
|
||||
&SaInboxSuggestion{},
|
||||
&SaTask{},
|
||||
&SaDocument{},
|
||||
&SaDocumentTree{},
|
||||
&SaDocumentContent{},
|
||||
&SaDocumentBlob{},
|
||||
&SaDocumentShare{},
|
||||
|
||||
Reference in New Issue
Block a user