-
Notifications
You must be signed in to change notification settings - Fork 12
/
repositories.go
35 lines (28 loc) · 930 Bytes
/
repositories.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package repository
import (
repository "github.com/openline-ai/openline-customer-os/packages/server/customer-os-common-auth/repository/postgres"
authEntity "github.com/openline-ai/openline-customer-os/packages/server/customer-os-common-auth/repository/postgres/entity"
"gorm.io/gorm"
)
type Repositories struct {
OAuthTokenRepository repository.OAuthTokenRepository
SlackSettingsRepository repository.SlackSettingsRepository
}
func InitRepositories(db *gorm.DB) *Repositories {
repositories := &Repositories{
OAuthTokenRepository: repository.NewOAuthTokenRepository(db),
SlackSettingsRepository: repository.NewSlackSettingsRepository(db),
}
return repositories
}
func (r *Repositories) Migration(db *gorm.DB) {
var err error
err = db.AutoMigrate(&authEntity.OAuthTokenEntity{})
if err != nil {
panic(err)
}
err = db.AutoMigrate(&authEntity.SlackSettingsEntity{})
if err != nil {
panic(err)
}
}