-
Notifications
You must be signed in to change notification settings - Fork 0
/
mapjumps.go
66 lines (63 loc) · 1.45 KB
/
mapjumps.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package universe
import "database/sql"
var dmls = []string{
`INSERT INTO "mapSolarSystemJumps" (
"fromRegionID",
"fromConstellationID",
"fromSolarSystemID",
"toRegionID",
"toConstellationID",
"toSolarSystemID"
) SELECT
f."regionID" AS "regionID",
f."constellationID" AS "fromConstellationID",
f."solarSystemID" AS "fromSolarSystemID",
t."regionID" AS "toRegionID",
t."constellationID" AS "toConstellationID",
t."solarSystemID" AS "toSolarSystemID"
FROM
"mapJumps"
JOIN
"mapDenormalize" AS f
ON
"mapJumps"."stargateID"=f."itemID"
JOIN
"mapDenormalize" AS t
ON
"mapJumps"."destinationID"=t."itemID"`,
`INSERT INTO "mapRegionJumps"
SELECT
DISTINCT f."regionID", t."regionID"
FROM
"mapJumps"
JOIN "mapDenormalize" AS f
on "mapJumps"."stargateID"=f."itemID"
JOIN "mapDenormalize" AS t
ON
"mapJumps"."destinationID"=t."itemID"
WHERE
f."regionID" != t."regionID"`,
`INSERT INTO "mapConstellationJumps"
SELECT DISTINCT
f."regionID",
f."constellationID",
t."constellationID",
t."regionID"
FROM
"mapJumps"
JOIN "mapDenormalize" AS f
on "mapJumps"."stargateID" = f."itemID"
JOIN "mapDenormalize" AS t
on "mapJumps"."destinationID"=t."itemID"
WHERE f."constellationID" != t."constellationID"`,
}
func FixMapJumps(db *sql.DB) error {
var err error
for _, dml := range dmls {
_, err = db.Exec(dml)
if err != nil {
return err
}
}
return nil
}