A web blog and personal homepage engine written in Go.
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.

24 lines
435 B

  1. package models
  2. import (
  3. "time"
  4. "github.com/jinzhu/gorm"
  5. )
  6. // DB is the database handle for all the models.
  7. var DB *gorm.DB
  8. // BaseModel is the base column set for all models.
  9. type BaseModel struct {
  10. ID int `gorm:"primary_key"`
  11. CreatedAt time.Time
  12. UpdatedAt time.Time
  13. }
  14. // UseDB registers a database driver.
  15. func UseDB(db *gorm.DB) {
  16. DB = db
  17. DB.AutoMigrate(&User{}, &Post{}, &TaggedPost{}, &Comment{}, &Question{})
  18. }