···11+package backfill
22+33+type AccountStatus string
44+55+var (
66+ // AccountStatusActive is not in the spec but used internally
77+ AccountStatusActive = AccountStatus("active")
88+99+ AccountStatusDeactivated = AccountStatus("deactivated")
1010+ AccountStatusDeleted = AccountStatus("deleted")
1111+ AccountStatusSuspended = AccountStatus("suspended")
1212+ AccountStatusTakendown = AccountStatus("takendown")
1313+ AccountStatusDesynchronized = AccountStatus("desynchronized")
1414+ AccountStatusThrottled = AccountStatus("throttled")
1515+1616+ // generic "not active, but not known" status
1717+ AccountStatusInactive = AccountStatus("inactive")
1818+)
1919+2020+type Account struct {
2121+ UID uint64 `gorm:"column:uid;primarykey" json:"uid"`
2222+ DID string `gorm:"column:did;uniqueIndex;not null" json:"did"`
2323+2424+ // this is a reference to the ID field on Host; but it is not an explicit foreign key
2525+ HostID uint64 `gorm:"column:host_id;not null" json:"hostID"`
2626+ Status AccountStatus `gorm:"column:status;not null;default:active" json:"status"`
2727+ UpstreamStatus AccountStatus `gorm:"column:upstream_status;not null;default:active" json:"upstreamStatus"`
2828+}
2929+3030+func (Account) TableName() string {
3131+ return "account"
3232+}
3333+3434+// This is a small extension table to `Account`, which holds fast-changing fields updated on every firehose event.
3535+type AccountRepo struct {
3636+ // references Account.UID, but not set up as a foreign key
3737+ UID uint64 `gorm:"column:uid;primarykey" json:"uid"`
3838+ Rev string `gorm:"column:rev;not null" json:"rev"`
3939+4040+ // The CID of the entire signed commit block. Sometimes called the "head"
4141+ CommitCID string `gorm:"column:commit_cid;not null" json:"commitCID"`
4242+4343+ // The CID of the top of the repo MST, which is the 'data' field within the commit block. This becomes 'prevData'
4444+ CommitDataCID string `gorm:"column:commit_data_cid;not null" json:"commitDataCID"`
4545+}
4646+4747+func (AccountRepo) TableName() string {
4848+ return "account_repo"
4949+}