website/pkg/models/models.go

50 lines
1.3 KiB
Go
Raw Normal View History

// Package models handles the database.
package models
import "gorm.io/gorm"
// DB to be set by calling app (SQLite or Postgres connection).
var DB *gorm.DB
// AutoMigrate the schema.
func AutoMigrate() {
DB.AutoMigrate(
// User and user-generated data.
// ✔ = models are cleaned up on DeleteUser()
&AdminGroup{}, // ✔ admin_group_users
&Block{}, // ✔
&CertificationPhoto{}, // ✔
&ChangeLog{}, // ✔
&Comment{}, // ✔
&CommentPhoto{}, // ✔
&Feedback{}, // ✔
&ForumMembership{}, // ✔
&Friend{}, // ✔
&IPAddress{}, // ✔
&Like{}, // ✔
&Message{}, // ✔
&Notification{}, // ✔
&ProfileField{}, // ✔
&Photo{}, // ✔
&PollVote{}, // keep their vote on polls
&Poll{}, // vacuum script cleans up orphaned polls
&PrivatePhoto{}, // ✔
&PushNotification{}, // ✔
&Subscription{}, // ✔
&Thread{}, // ✔
&TwoFactor{}, // ✔
&UsageStatistic{}, // ✔
&User{}, // ✔
&UserLocation{}, // ✔
&UserNote{}, // ✔
// Non-user or persistent data.
&AdminScope{},
&Forum{},
// Vendor/misc data.
&WorldCities{},
)
}