feat: Add migration scripts for users and auth_tokens tables, including up and down operations

This commit is contained in:
begoniezhao
2025-12-04 20:50:50 +08:00
parent 1aa66bfa10
commit a8143dc85a
5 changed files with 107 additions and 10 deletions
-10
View File
@@ -275,16 +275,6 @@ func initDatabase(cfg *config.Config) (*gorm.DB, error) {
return nil, err
}
// Auto-migrate database tables
err = db.AutoMigrate(
&types.User{},
&types.AuthToken{},
&types.KnowledgeBase{},
)
if err != nil {
return nil, fmt.Errorf("failed to auto-migrate database tables: %v", err)
}
// Run database migrations automatically (optional, can be disabled via env var)
// To disable auto-migration, set AUTO_MIGRATE=false
if os.Getenv("AUTO_MIGRATE") != "false" {