package database import ( "time" ) type FirehoseCursor struct { ID uint `gorm:"primaryKey"` Seq int64 `gorm:"not null"` UpdatedAt time.Time `gorm:"autoUpdateTime"` } func (FirehoseCursor) TableName() string { return "firehose_cursor" } type Subscription struct { ID uint `gorm:"primaryKey" json:"-"` DID string `gorm:"column:did;size:255;not null;index:idx_subscriptions_did_rkey,unique;index:idx_subscriptions_did" json:"did"` Rkey string `gorm:"size:512;not null;index:idx_subscriptions_did_rkey,unique" json:"rkey"` FeedID int64 `gorm:"not null;index:idx_subscriptions_feed_id" json:"feed_id"` FeedURL string `gorm:"size:2048" json:"feed_url"` PodcastGuid string `gorm:"size:512" json:"podcast_guid"` CreatedAt string `gorm:"size:64;not null" json:"created_at"` IndexedAt time.Time `gorm:"autoCreateTime" json:"-"` } func (Subscription) TableName() string { return "subscriptions" } type Comment struct { ID uint `gorm:"primaryKey" json:"-"` DID string `gorm:"column:did;size:255;not null;index:idx_comments_did_rkey,unique;index:idx_comments_did" json:"did"` Rkey string `gorm:"size:512;not null;index:idx_comments_did_rkey,unique" json:"rkey"` ATURI string `gorm:"column:at_uri;size:1024;index;not null" json:"at_uri"` FeedID int64 `gorm:"not null;index:idx_comments_episode" json:"feed_id"` EpisodeID int64 `gorm:"not null;index:idx_comments_episode" json:"episode_id"` EpisodeGuid string `gorm:"size:512" json:"episode_guid"` PodcastGuid string `gorm:"size:512" json:"podcast_guid"` Text string `gorm:"type:text;not null" json:"text"` TimestampS *int `gorm:"index" json:"timestamp_s"` ReplyRoot string `gorm:"size:1024;index:idx_comments_reply_root" json:"reply_root"` ReplyParent string `gorm:"size:1024" json:"reply_parent"` Facets []byte `gorm:"type:jsonb" json:"facets"` CreatedAt string `gorm:"size:64;not null" json:"created_at"` IndexedAt time.Time `gorm:"autoCreateTime" json:"-"` } func (Comment) TableName() string { return "comments" } type Recommendation struct { ID uint `gorm:"primaryKey" json:"-"` DID string `gorm:"column:did;size:255;not null;index:idx_recommendations_did_rkey,unique;index:idx_recommendations_did" json:"did"` Rkey string `gorm:"size:512;not null;index:idx_recommendations_did_rkey,unique" json:"rkey"` FeedID int64 `gorm:"not null;index:idx_recommendations_episode" json:"feed_id"` EpisodeID int64 `gorm:"not null;index:idx_recommendations_episode" json:"episode_id"` EpisodeGuid string `gorm:"size:512" json:"episode_guid"` PodcastGuid string `gorm:"size:512" json:"podcast_guid"` Text string `gorm:"type:text" json:"text"` CreatedAt string `gorm:"size:64;not null" json:"created_at"` IndexedAt time.Time `gorm:"autoCreateTime" json:"-"` } func (Recommendation) TableName() string { return "recommendations" } type PodcastList struct { ID uint `gorm:"primaryKey" json:"-"` DID string `gorm:"column:did;size:255;not null;index:idx_lists_did_rkey,unique;index:idx_lists_did" json:"did"` Rkey string `gorm:"size:512;not null;index:idx_lists_did_rkey,unique" json:"rkey"` Name string `gorm:"size:500;not null" json:"name"` Description string `gorm:"type:text" json:"description"` Podcasts []byte `gorm:"type:jsonb;not null" json:"-"` CreatedAt string `gorm:"size:64;not null" json:"created_at"` IndexedAt time.Time `gorm:"autoCreateTime" json:"-"` } func (PodcastList) TableName() string { return "podcast_lists" } type Bookmark struct { ID uint `gorm:"primaryKey" json:"-"` DID string `gorm:"column:did;size:255;not null;index:idx_bookmarks_did_rkey,unique;index:idx_bookmarks_did" json:"did"` Rkey string `gorm:"size:512;not null;index:idx_bookmarks_did_rkey,unique" json:"rkey"` FeedID int64 `gorm:"not null;index:idx_bookmarks_episode" json:"feed_id"` EpisodeID int64 `gorm:"not null;index:idx_bookmarks_episode" json:"episode_id"` EpisodeGuid string `gorm:"size:512" json:"episode_guid"` PodcastGuid string `gorm:"size:512" json:"podcast_guid"` TimestampS *int `gorm:"index" json:"timestamp"` CreatedAt string `gorm:"size:64;not null" json:"created_at"` IndexedAt time.Time `gorm:"autoCreateTime" json:"-"` } func (Bookmark) TableName() string { return "bookmarks" } type Profile struct { DID string `gorm:"column:did;primaryKey;size:255" json:"did"` DisplayName string `gorm:"size:640" json:"display_name"` Description string `gorm:"type:text" json:"description"` FavoriteGenres []byte `gorm:"type:jsonb" json:"-"` IndexedAt time.Time `gorm:"autoCreateTime" json:"-"` } func (Profile) TableName() string { return "profiles" } type PICache struct { ID uint `gorm:"primaryKey"` CacheKey string `gorm:"uniqueIndex;size:512"` Response []byte `gorm:"type:jsonb;not null"` ExpiresAt time.Time `gorm:"index:idx_pi_cache_expires;not null"` CreatedAt time.Time `gorm:"autoCreateTime"` UpdatedAt time.Time `gorm:"autoUpdateTime"` } func (PICache) TableName() string { return "pi_cache" } type PodcastStats struct { FeedID int64 `gorm:"primaryKey"` SubscriberCount int `gorm:"default:0"` CommentCount int `gorm:"default:0"` RecommendationCount int `gorm:"default:0"` LastUpdated time.Time `gorm:"autoUpdateTime"` } func (PodcastStats) TableName() string { return "podcast_stats" } type EpisodeStats struct { EpisodeID int64 `gorm:"primaryKey"` FeedID int64 `gorm:"not null;index:idx_episode_stats_feed"` CommentCount int `gorm:"default:0"` RecommendationCount int `gorm:"default:0"` BookmarkCount int `gorm:"default:0"` LastUpdated time.Time `gorm:"autoUpdateTime"` } func (EpisodeStats) TableName() string { return "episode_stats" } type EpisodeState struct { ID uint `gorm:"primaryKey" json:"-"` DID string `gorm:"column:did;size:255;not null;index:idx_episode_states_did_rkey,unique;index:idx_episode_states_did" json:"did"` Rkey string `gorm:"size:512;not null;index:idx_episode_states_did_rkey,unique" json:"rkey"` FeedID int64 `gorm:"not null;index:idx_episode_states_episode,unique" json:"feed_id"` EpisodeID int64 `gorm:"not null;index:idx_episode_states_episode,unique" json:"episode_id"` EpisodeGuid string `gorm:"size:512" json:"episode_guid"` PodcastGuid string `gorm:"size:512" json:"podcast_guid"` PositionS *int `json:"position_s"` DurationS *int `json:"duration_s"` Played bool `gorm:"default:false" json:"played"` Saved bool `gorm:"default:false" json:"saved"` Hidden bool `gorm:"default:false" json:"hidden"` UpdatedAt string `gorm:"size:64" json:"updated_at"` CreatedAt string `gorm:"size:64;not null" json:"created_at"` IndexedAt time.Time `gorm:"autoCreateTime" json:"-"` } func (EpisodeState) TableName() string { return "episode_states" } type Block struct { ID uint `gorm:"primaryKey" json:"-"` DID string `gorm:"column:did;size:255;not null;index:idx_blocks_did_rkey,unique;index:idx_blocks_did;index:idx_blocks_did_subject,unique" json:"did"` Rkey string `gorm:"size:512;not null;index:idx_blocks_did_rkey,unique" json:"rkey"` ATURI string `gorm:"column:at_uri;size:1024;not null;index" json:"-"` SubjectDID string `gorm:"column:subject_did;size:255;not null;index:idx_blocks_subject;index:idx_blocks_did_subject,unique" json:"subject_did"` CreatedAt string `gorm:"size:64;not null" json:"created_at"` IndexedAt time.Time `gorm:"autoCreateTime" json:"-"` } func (Block) TableName() string { return "blocks" } type Report struct { ID uint `gorm:"primaryKey" json:"-"` DID string `gorm:"column:did;size:255;not null;index:idx_reports_did_rkey,unique;index:idx_reports_did" json:"did"` Rkey string `gorm:"size:512;not null;index:idx_reports_did_rkey,unique" json:"rkey"` SubjectURI string `gorm:"size:1024;not null" json:"subject_uri"` ReasonType string `gorm:"size:64;not null" json:"reason_type"` Reason string `gorm:"type:text" json:"reason"` Status string `gorm:"size:64;not null;default:pending;index:idx_reports_status" json:"status"` CreatedAt string `gorm:"size:64;not null" json:"created_at"` IndexedAt time.Time `gorm:"autoCreateTime" json:"-"` } func (Report) TableName() string { return "reports" } // AttestChallenge stores one-time nonces for the App Attest device registration flow. type AttestChallenge struct { ID uint `gorm:"primaryKey"` Nonce string `gorm:"size:64;uniqueIndex;not null"` ExpiresAt time.Time `gorm:"index;not null"` CreatedAt time.Time `gorm:"autoCreateTime"` } func (AttestChallenge) TableName() string { return "attest_challenges" } // DeviceToken stores server-issued bearer tokens for App Attest verified devices. type DeviceToken struct { ID uint `gorm:"primaryKey"` Token string `gorm:"size:128;uniqueIndex;not null"` KeyID string `gorm:"size:128;not null"` PublicKey []byte `gorm:"type:bytea;not null"` Environment string `gorm:"size:24;not null;default:production"` LastUsedAt time.Time `gorm:"autoUpdateTime"` CreatedAt time.Time `gorm:"autoCreateTime"` RevokedAt *time.Time `gorm:"index"` } func (DeviceToken) TableName() string { return "device_tokens" }