Forum software. Server rendered, HTML!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
formless/database/model.go

31 lines
624 B

package database
import (
"time"
"github.com/google/uuid"
"github.com/jinzhu/gorm"
"github.com/rs/zerolog/log"
_ "github.com/jinzhu/gorm/dialects/sqlite"
)
type User struct {
gorm.Model
UUID uuid.UUID `gorm:"type:uuid;primary_key;"`
Username string `gorm:"unique_index"`
Created time.Time
}
type Post struct {
gorm.Model
UUID uuid.UUID `gorm:"type:uuid;primary_key;"`
Body string
}
// NB that when you add a model below you must add it to this list!
func (m *Manager) doMigrations() {
log.Info().Msg("doing database migrations if required")
m.db.AutoMigrate(&User{})
m.db.AutoMigrate(&Post{})
}