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
|
package backend
import (
"database/sql"
"log"
)
// InitStarsTable initialises the stars table
func InitStarsTable(db *sql.DB) {
query := `CREATE TABLE public.stars
(
star_id bigint NOT NULL DEFAULT nextval('stars_star_id_seq'::regclass),
x numeric,
y numeric,
vx numeric,
vy numeric,
m numeric
)
`
_, err := db.Exec(query)
if err != nil {
log.Fatalf("[ E ] InitNodesTable query: %v \n\t\t\tquery: %s\n", err, query)
}
}
// InitNodesTable initialises the nodes table
func InitNodesTable(db *sql.DB) {
query := `CREATE TABLE public.nodes
(
node_id bigint NOT NULL DEFAULT nextval('nodes_node_id_seq'::regclass),
box_width numeric NOT NULL,
total_mass numeric NOT NULL,
depth integer,
star_id bigint NOT NULL,
root_id bigint NOT NULL,
isleaf boolean,
box_center numeric[] NOT NULL,
center_of_mass numeric[] NOT NULL,
subnodes bigint[] NOT NULL
)
`
_, err := db.Exec(query)
if err != nil {
log.Fatalf("[ E ] InitNodesTable query: %v \n\t\t\tquery: %s\n", err, query)
}
}
|