Started to work on media upload and organization
This commit is contained in:
@@ -136,6 +136,17 @@ type WebsiteSettings struct {
|
||||
AutoAcceptDemand bool `bun:"auto_accept_demand,default:false" json:"autoAcceptDemand"`
|
||||
}
|
||||
|
||||
type Media struct {
|
||||
ID uuid.UUID `bun:"type:uuid,pk,default:gen_random_uuid()" json:"id"`
|
||||
AuthorID uuid.UUID `bun:"author_id,type:uuid,notnull" json:"authorID"`
|
||||
Author *User `bun:"rel:belongs-to,join:author_id=user_id" json:"author,omitempty"`
|
||||
Type string `bun:"media_type" json:"type"` // Image, Video, GIF etc. Add support for PDFs?
|
||||
Alt string `bun:"media_alt" json:"alt"`
|
||||
Path string `bun:"media_path" json:"path"`
|
||||
Size int64 `bun:"media_size" json:"size"`
|
||||
URL string `bun:"-" json:"url"`
|
||||
}
|
||||
|
||||
func InitDatabase(dsn DSN) (*bun.DB, error) {
|
||||
sqldb := sql.OpenDB(pgdriver.NewConnector(pgdriver.WithDSN(dsn.ToString())))
|
||||
db := bun.NewDB(sqldb, pgdialect.New())
|
||||
@@ -152,6 +163,7 @@ func InitDatabase(dsn DSN) (*bun.DB, error) {
|
||||
_, err = db.NewCreateTable().Model((*EventToUser)(nil)).IfNotExists().Exec(ctx)
|
||||
_, err = db.NewCreateTable().Model((*Blog)(nil)).IfNotExists().Exec(ctx)
|
||||
_, err = db.NewCreateTable().Model((*WebsiteSettings)(nil)).IfNotExists().Exec(ctx)
|
||||
_, err = db.NewCreateTable().Model((*Media)(nil)).IfNotExists().Exec(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user