feat(migrations): Harden task audit tracking and optimize article templates
- Added migration to harden task audit tracking by modifying audit_logs and related tables. - Introduced operator_id to several tables for better tracking of actions. - Updated article_templates with new prompt templates for various article types, enhancing content generation. - Created prompt_rules and schedule_tasks tables to manage content generation rules and scheduling. - Added foreign key constraints to articles for better data integrity.
This commit is contained in:
@@ -20,6 +20,7 @@ type Article struct {
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
|
||||
WizardStateJson []byte `json:"wizard_state_json"`
|
||||
}
|
||||
|
||||
type ArticleTemplate struct {
|
||||
@@ -55,15 +56,19 @@ type ArticleVersion struct {
|
||||
}
|
||||
|
||||
type AuditLog struct {
|
||||
ID int64 `json:"id"`
|
||||
OperatorID int64 `json:"operator_id"`
|
||||
TenantID pgtype.Int8 `json:"tenant_id"`
|
||||
Module string `json:"module"`
|
||||
Action string `json:"action"`
|
||||
BeforeJson []byte `json:"before_json"`
|
||||
AfterJson []byte `json:"after_json"`
|
||||
Result pgtype.Text `json:"result"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
ID int64 `json:"id"`
|
||||
OperatorID int64 `json:"operator_id"`
|
||||
TenantID pgtype.Int8 `json:"tenant_id"`
|
||||
Module string `json:"module"`
|
||||
Action string `json:"action"`
|
||||
BeforeJson []byte `json:"before_json"`
|
||||
AfterJson []byte `json:"after_json"`
|
||||
Result pgtype.Text `json:"result"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
ResourceType pgtype.Text `json:"resource_type"`
|
||||
ResourceID pgtype.Int8 `json:"resource_id"`
|
||||
RequestID pgtype.Text `json:"request_id"`
|
||||
ErrorMessage pgtype.Text `json:"error_message"`
|
||||
}
|
||||
|
||||
type Brand struct {
|
||||
@@ -138,6 +143,7 @@ type GenerationTask struct {
|
||||
CompletedAt pgtype.Timestamptz `json:"completed_at"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
OperatorID pgtype.Int8 `json:"operator_id"`
|
||||
}
|
||||
|
||||
type Plan struct {
|
||||
@@ -160,12 +166,37 @@ type PlatformUserRole struct {
|
||||
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
|
||||
}
|
||||
|
||||
type PromptRule struct {
|
||||
ID int64 `json:"id"`
|
||||
TenantID int64 `json:"tenant_id"`
|
||||
GroupID pgtype.Int8 `json:"group_id"`
|
||||
Name string `json:"name"`
|
||||
PromptContent string `json:"prompt_content"`
|
||||
Scene pgtype.Text `json:"scene"`
|
||||
DefaultTone pgtype.Text `json:"default_tone"`
|
||||
DefaultWordCount pgtype.Int4 `json:"default_word_count"`
|
||||
Status string `json:"status"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
|
||||
}
|
||||
|
||||
type PromptRuleGroup struct {
|
||||
ID int64 `json:"id"`
|
||||
TenantID int64 `json:"tenant_id"`
|
||||
Name string `json:"name"`
|
||||
SortOrder int32 `json:"sort_order"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
|
||||
}
|
||||
|
||||
type QuotaReservation struct {
|
||||
ID int64 `json:"id"`
|
||||
TenantID int64 `json:"tenant_id"`
|
||||
QuotaType string `json:"quota_type"`
|
||||
ResourceType string `json:"resource_type"`
|
||||
ResourceID int64 `json:"resource_id"`
|
||||
ResourceID pgtype.Int8 `json:"resource_id"`
|
||||
ReservedAmount int32 `json:"reserved_amount"`
|
||||
ConsumedAmount int32 `json:"consumed_amount"`
|
||||
RefundedAmount int32 `json:"refunded_amount"`
|
||||
@@ -173,6 +204,24 @@ type QuotaReservation struct {
|
||||
ExpireAt pgtype.Timestamptz `json:"expire_at"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
OperatorID pgtype.Int8 `json:"operator_id"`
|
||||
}
|
||||
|
||||
type ScheduleTask struct {
|
||||
ID int64 `json:"id"`
|
||||
TenantID int64 `json:"tenant_id"`
|
||||
PromptRuleID int64 `json:"prompt_rule_id"`
|
||||
BrandID pgtype.Int8 `json:"brand_id"`
|
||||
Name string `json:"name"`
|
||||
CronExpr string `json:"cron_expr"`
|
||||
TargetPlatform pgtype.Text `json:"target_platform"`
|
||||
StartAt pgtype.Timestamptz `json:"start_at"`
|
||||
EndAt pgtype.Timestamptz `json:"end_at"`
|
||||
NextRunAt pgtype.Timestamptz `json:"next_run_at"`
|
||||
Status string `json:"status"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
|
||||
}
|
||||
|
||||
type TaskRecord struct {
|
||||
@@ -187,6 +236,23 @@ type TaskRecord struct {
|
||||
ErrorMessage pgtype.Text `json:"error_message"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
OperatorID pgtype.Int8 `json:"operator_id"`
|
||||
}
|
||||
|
||||
type TemplateAssistTask struct {
|
||||
ID string `json:"id"`
|
||||
TenantID int64 `json:"tenant_id"`
|
||||
TemplateID int64 `json:"template_id"`
|
||||
Status string `json:"status"`
|
||||
RequestJson []byte `json:"request_json"`
|
||||
ResultJson []byte `json:"result_json"`
|
||||
ErrorMessage pgtype.Text `json:"error_message"`
|
||||
StartedAt pgtype.Timestamptz `json:"started_at"`
|
||||
CompletedAt pgtype.Timestamptz `json:"completed_at"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
||||
TaskType string `json:"task_type"`
|
||||
OperatorID pgtype.Int8 `json:"operator_id"`
|
||||
}
|
||||
|
||||
type Tenant struct {
|
||||
@@ -231,6 +297,7 @@ type TenantQuotaLedger struct {
|
||||
ReferenceType pgtype.Text `json:"reference_type"`
|
||||
ReferenceID pgtype.Int8 `json:"reference_id"`
|
||||
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
||||
OperatorID pgtype.Int8 `json:"operator_id"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
|
||||
Reference in New Issue
Block a user