start on reports, uuidv7 for id
This commit is contained in:
+9
-1
@@ -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())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user