website/pkg/models/models.go
Noah Petherbridge 90d0d10ee5 Adopt a Forum
* Forums are disowned on user account deletion (their owner_id=0)
* A forum without an owner shows a notice at the bottom with a link to petition
  to adopt the forum. It goes to the Contact form with a special subject.
  * Note: there is no easy way to re-assign ownership yet other than a direct
    database query.
* Code cleanup
  * Alphabetize the DB.AutoMigrate tables.
  * Delete more things on user deletion: forum_memberships, admin_group_users
  * Vacuum worker to clean up orphaned polls after the threads are removed
2024-08-23 22:56:40 -07:00

49 lines
1.3 KiB
Go

// 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{}, // ✔
&Thread{}, // ✔
&TwoFactor{}, // ✔
&Subscription{}, // ✔
&User{}, // ✔
&UserLocation{}, // ✔
&UserNote{}, // ✔
// Non-user or persistent data.
&AdminScope{},
&Forum{},
// Vendor/misc data.
&WorldCities{},
)
}