2022-08-10 05:10:47 +00:00
|
|
|
// 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() {
|
2024-08-24 04:21:42 +00:00
|
|
|
|
|
|
|
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{}, // ✔
|
2024-12-06 05:49:19 +00:00
|
|
|
&MutedUser{}, // ✔
|
2024-08-24 04:21:42 +00:00
|
|
|
&Notification{}, // ✔
|
|
|
|
&ProfileField{}, // ✔
|
|
|
|
&Photo{}, // ✔
|
|
|
|
&PollVote{}, // keep their vote on polls
|
|
|
|
&Poll{}, // vacuum script cleans up orphaned polls
|
|
|
|
&PrivatePhoto{}, // ✔
|
|
|
|
&PushNotification{}, // ✔
|
2024-09-12 02:28:52 +00:00
|
|
|
&Subscription{}, // ✔
|
2024-08-24 04:21:42 +00:00
|
|
|
&Thread{}, // ✔
|
|
|
|
&TwoFactor{}, // ✔
|
2024-09-12 02:28:52 +00:00
|
|
|
&UsageStatistic{}, // ✔
|
2024-08-24 04:21:42 +00:00
|
|
|
&User{}, // ✔
|
|
|
|
&UserLocation{}, // ✔
|
|
|
|
&UserNote{}, // ✔
|
|
|
|
|
|
|
|
// Non-user or persistent data.
|
|
|
|
&AdminScope{},
|
|
|
|
&Forum{},
|
|
|
|
|
|
|
|
// Vendor/misc data.
|
|
|
|
&WorldCities{},
|
|
|
|
)
|
2022-08-10 05:10:47 +00:00
|
|
|
}
|