feat: add description field to Category model and clean up migration code
This commit is contained in:
parent
dc1a4dafbc
commit
479703dfd0
@ -5,13 +5,14 @@ import (
|
||||
)
|
||||
|
||||
type Category struct {
|
||||
ID string `gorm:"primaryKey" json:"id"`
|
||||
Name string `gorm:"not null" json:"name"`
|
||||
Code string `gorm:"not null;unique" json:"code"`
|
||||
Sequence int `gorm:"default:null" json:"sequence"`
|
||||
CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
|
||||
DeletedAt time.Time `gorm:"default:null" json:"deleted_at"`
|
||||
ID string `gorm:"primaryKey" json:"id"`
|
||||
Name string `gorm:"not null" json:"name"`
|
||||
Code string `gorm:"not null;unique" json:"code"`
|
||||
Description string `gorm:"default:null" json:"description"`
|
||||
Sequence int `gorm:"default:null" json:"sequence"`
|
||||
CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
|
||||
DeletedAt time.Time `gorm:"default:null" json:"deleted_at"`
|
||||
|
||||
News []News `gorm:"many2many:news_categories" json:"news"`
|
||||
}
|
||||
|
||||
@ -39,10 +39,6 @@ func NewDB(cfg *config.Config) (*DB, error) {
|
||||
func (db *DB) DropTables() error {
|
||||
// Auto Migrate the User model
|
||||
return db.Migrator().DropTable(
|
||||
// &Staff{},
|
||||
// &SubscribePlan{},
|
||||
// &Subscribe{},
|
||||
// &User{},
|
||||
&Tag{},
|
||||
&Category{},
|
||||
&News{},
|
||||
@ -55,9 +51,6 @@ func (db *DB) Migrate() error {
|
||||
&SubscribePlan{},
|
||||
&Subscribe{},
|
||||
&User{},
|
||||
// &Tag{},
|
||||
// &Category{},
|
||||
// &News{},
|
||||
&News{},
|
||||
&Tag{},
|
||||
&Category{},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user