-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
50 lines (44 loc) · 979 Bytes
/
main.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"archie/connection/postgres_conn"
"archie/models"
"archie/routes"
"archie/services"
"archie/utils/db_utils/db_migrate_utils"
_ "gorm.io/driver/postgres"
"gorm.io/gorm"
"math/rand"
"time"
)
func initTable() {
db_migrate_utils.InitTable(func(db *gorm.DB) error {
if err := db.AutoMigrate(
models.UserOrganization{},
models.User{},
models.Message{},
models.Organization{},
models.RolePermission{},
models.Role{},
models.Permission{},
models.Category{},
models.DocumentContributor{},
models.Document{},
models.DocumentPermission{},
models.OrganizationPermission{},
models.Comment{},
models.CommentStatus{},
models.Member{},
); err != nil {
return err
}
return db.SetupJoinTable(&models.Organization{}, "Members", &models.Member{})
})
}
func main() {
rand.Seed(time.Now().UnixNano())
// init database
postgres_conn.DB.InitDB()
go services.Receiver.Run()
initTable()
routes.Serve()
}