Remove id autogeneration from db models
Remove automatic uuid v4 ID generation from the models and replace it with `shared.NewId()`, which generates an Id depending on the config setting
This commit is contained in:
parent
412a8be600
commit
e182949a8d
9 changed files with 24 additions and 12 deletions
|
@ -12,7 +12,7 @@ import (
|
|||
// Instead, they are either stored on the remote server they originated from
|
||||
// or an s3 bucket if uploaded to Linstrom.
|
||||
type MediaMetadata struct {
|
||||
ID string `gorm:"primarykey;default:gen_random_uuid()"` // The unique ID of this media file
|
||||
ID string `gorm:"primarykey"` // The unique ID of this media file
|
||||
CreatedAt time.Time // When this entry was created
|
||||
UpdatedAt time.Time // When this entry was last updated
|
||||
// When this entry was deleted (for soft deletions)
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
// A note describes some user generated text content.
|
||||
type Note struct {
|
||||
ID string `gorm:"primarykey;default:gen_random_uuid()"` // Make ID a string (uuid) for other implementations
|
||||
ID string `gorm:"primarykey"` // Make ID a string for other implementations
|
||||
CreatedAt time.Time // When this entry was created
|
||||
UpdatedAt time.Time // When this entry was last updated
|
||||
// When this entry was deleted (for soft deletions)
|
||||
|
|
|
@ -14,7 +14,7 @@ type AccessToken struct {
|
|||
User User // The account the token belongs to
|
||||
UserId string
|
||||
// The token itself is a uuid value
|
||||
Token string `gorm:"primarykey;type:uuid;default:gen_random_uuid()"`
|
||||
Token string `gorm:"primarykey"`
|
||||
Name string // Token name will be empty if autogenerated with sucessful login
|
||||
// Every token expires, even if set to "not expire". If set to "not expire", it just expires
|
||||
// at a point in the future this server should never reach
|
||||
|
|
|
@ -10,7 +10,7 @@ type LoginProcessToken struct {
|
|||
ID uint64 `gorm:"primarykey"`
|
||||
User User
|
||||
UserId string `gorm:"unique"`
|
||||
Token string `gorm:"type:uuid;default:gen_random_uuid()"`
|
||||
Token string
|
||||
Name string
|
||||
ExpiresAt time.Time
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ type User struct {
|
|||
// Same also applies for other types that use a UUID as primary key
|
||||
// TODO: Change this to generate via cuid or uuid, depending on config
|
||||
// Or remove autogeneration alltogether
|
||||
ID string `gorm:"primarykey;default:gen_random_uuid()"`
|
||||
ID string `gorm:"primarykey"`
|
||||
// Username of the user (eg "max" if the full username is @max@example.com)
|
||||
// Assume unchangable (once set by a user) to be kind to other implementations
|
||||
// Would be an easy avenue to fuck with them though
|
||||
|
|
|
@ -129,6 +129,7 @@ func insertUser(
|
|||
)
|
||||
}
|
||||
user := models.User{
|
||||
ID: shared.NewId(),
|
||||
Username: shared.ServerActorName,
|
||||
Server: *server,
|
||||
ServerId: server.ID,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue