Add database indexes for better query performance and allow robots.txt access

This commit is contained in:
2025-06-25 15:57:50 +03:30
parent 95f5e03f65
commit d266c93b8a
2 changed files with 5 additions and 5 deletions

View File

@@ -5,11 +5,11 @@ type Post struct {
Url string `json:"url"` Url string `json:"url"`
AccountID string // Foreign key field (must match Account.AccId) AccountID string // Foreign key field (must match Account.AccId)
Account Account `json:"account" gorm:"foreignKey:AccountID;references:AccId"` Account Account `json:"account" gorm:"foreignKey:AccountID;references:AccId"`
Attachments []MediaAttachment `json:"media_attachments" gorm:"foreignKey:PostID;references:ID"` Attachments []MediaAttachment `json:"media_attachments" gorm:"foreignKey:PostID;references:ID;index:idx_post_attachments"`
} }
type Account struct { type Account struct {
AccId string `json:"id" gorm:"primaryKey"` AccId string `json:"id" gorm:"primaryKey;index"`
Username string `json:"username"` Username string `json:"username"`
Acct string `json:"acct"` Acct string `json:"acct"`
DisplayName string `json:"display_name"` DisplayName string `json:"display_name"`
@@ -24,7 +24,7 @@ type MediaAttachment struct {
Url string `json:"url"` Url string `json:"url"`
PreviewUrl string `json:"preview_url"` PreviewUrl string `json:"preview_url"`
RemoteUrl string `json:"remote_url"` RemoteUrl string `json:"remote_url"`
PostID string `gorm:"index:idx_post_approved"` // Foreign key to Post PostID string `gorm:"index:idx_post_approved,post_id;index:idx_post_id"`
Approved bool `json:"approved" gorm:"index:idx_post_approved"` Approved bool `json:"approved" gorm:"index:idx_post_approved"`
Rejected bool `json:"rejected" gorm:"index:idx_post_rejected"` Rejected bool `json:"rejected" gorm:"index:idx_post_rejected"`
} }

View File

@@ -1,2 +1,2 @@
User-agent: * User-agent: *
Disallow: / Allow: /