Starting to improve the project structure

This commit is contained in:
2025-05-17 18:43:54 +03:30
parent cb5149b7bc
commit ab9254fcad
11 changed files with 874 additions and 16 deletions
+20
View File
@@ -0,0 +1,20 @@
package database
import (
"CatsOfMastodonBotGo/internal/domain"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
func Connect() (*gorm.DB, error) {
db, err := gorm.Open(sqlite.Open("test.db"), &gorm.Config{})
if err != nil {
return nil, err
}
// Migrate the schema
if err := db.AutoMigrate(&domain.Post{}, &domain.MediaAttachment{}, &domain.Account{}); err != nil {
return nil, err
}
return db, nil
}