the beginning of the idiots

This commit is contained in:
2025-10-24 14:51:13 -05:00
parent 0b377030c6
commit cb06217ef7
123 changed files with 10279 additions and 0 deletions

40
qwen/go/db/db.go Normal file
View File

@@ -0,0 +1,40 @@
package db
import (
"log"
"mohportal/models"
"gorm.io/driver/postgres"
"gorm.io/gorm"
"gorm.io/gorm/logger"
)
var DB *gorm.DB
// ConnectDatabase connects to the database and runs migrations
func ConnectDatabase(url string) {
var err error
DB, err = gorm.Open(postgres.Open(url), &gorm.Config{
Logger: logger.Default.LogMode(logger.Info),
})
if err != nil {
log.Fatal("Failed to connect to database:", err)
}
// Run migrations
err = DB.AutoMigrate(
&models.Tenant{},
&models.User{},
&models.OIDCIdentity{},
&models.SocialIdentity{},
&models.JobPosition{},
&models.Resume{},
&models.Application{},
)
if err != nil {
log.Fatal("Failed to migrate database:", err)
}
log.Println("Database connected and migrated successfully")
}