diff options
author | Emile <hanemile@protonmail.com> | 2019-03-07 16:14:12 +0100 |
---|---|---|
committer | Emile <hanemile@protonmail.com> | 2019-03-07 16:14:12 +0100 |
commit | c8ca77ad65e9c0b31c6bd5289de0c1d332c06e63 (patch) | |
tree | ead406696f0c02a6b51e49a7dbcbbd1afce848c4 /backend/init.go | |
parent | 4d7880421ddc732d2f9fd3a2eaf1ca2c22a485c6 (diff) |
subdivided the project into multiple logical compartments
Diffstat (limited to 'backend/init.go')
-rw-r--r-- | backend/init.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/backend/init.go b/backend/init.go new file mode 100644 index 0000000..0e8303e --- /dev/null +++ b/backend/init.go @@ -0,0 +1,44 @@ +package backend + +import ( + "database/sql" + "log" +) + +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) + } +} + +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) + } +} |