package models import ( "gorm.io/driver/postgres" "gorm.io/gorm" ) var DBService *gorm.DB func New(dsn string) error { db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{}) if err != nil { return err } if err := AutoMigrate(db); err != nil { return err } DBService = db return nil } func AutoMigrate(database *gorm.DB) error { return database.AutoMigrate( &SenlinAgentUser{}, &SenlinAgentProject{}, &SenlinAgentInboxItem{}, &SenlinAgentTask{}, &SenlinAgentNote{}, &SenlinAgentSource{}, &SenlinAgentAISession{}, &SenlinAgentTag{}, &SenlinAgentProjectEvent{}, &SenlinAgentAIKey{}, &SenlinAgentAICallLog{}, &SenlinAgentTaskShare{}, ) }