start on reports, uuidv7 for id

This commit is contained in:
2026-11-19 10:58:33 -05:00
parent dc3b66cc58
commit f43cca319e
3 changed files with 12 additions and 2 deletions
+9 -1
View File
@@ -28,6 +28,14 @@ type Upload struct {
DeleteToken string `gorm:"column:delete_token;not null" json:"-"`
}
type Report struct {
ID string `gorm:"column:id;primaryKey"`
UploadID string
Reason string `gorm:"column:reason;not null"`
Upload Upload `gorm:"foreignKey:UploadID"`
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime"`
}
func initDatabase(path string) (*gorm.DB, error) {
db, err := gorm.Open(sqlite.Open(path), &gorm.Config{})
if err != nil {
@@ -46,7 +54,7 @@ func initDatabase(path string) (*gorm.DB, error) {
return nil, errors.Join(walModeErr, sqlDB.Close())
}
if err := db.AutoMigrate(&Upload{}); err != nil {
if err := db.AutoMigrate(&Upload{}, &Report{}); err != nil {
migrationErr := fmt.Errorf("migrate database: %w", err)
return nil, errors.Join(migrationErr, sqlDB.Close())
}