blob: d87d9621221a67ba7050b5890b2c74fc70853978 (
plain)
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
|
package schema
import (
"glsamaker/pkg/models"
"glsamaker/pkg/models/bugzilla"
"glsamaker/pkg/models/cve"
"glsamaker/pkg/models/users"
"github.com/go-pg/pg/v9"
"github.com/go-pg/pg/v9/orm"
)
// CreateSchema creates the tables in the database
// in case they don't alreay exist
func CreateSchema(dbCon *pg.DB) error {
for _, model := range []interface{}{
(*models.GlobalSettings)(nil),
(*models.ApplicationSetting)(nil),
(*users.User)(nil),
(*models.Session)(nil),
(*bugzilla.Bug)(nil),
(*models.Glsa)(nil),
(*models.GlsaToBug)(nil),
(*cve.Comment)(nil),
(*cve.DefCveItem)(nil),
(*cve.DefCveItemToBug)(nil)} {
err := dbCon.CreateTable(model, &orm.CreateTableOptions{
IfNotExists: true,
})
if err != nil {
return err
}
}
return nil
}
|