Starting to improve the project structure
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user