Skip to content

Commit 7fe1a79

Browse files
feat(database): add eddn_message table declaration
1 parent 286f697 commit 7fe1a79

File tree

4 files changed

+37
-19
lines changed

4 files changed

+37
-19
lines changed

Makefile

+24-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
PWD=$(shell pwd)
22
.DEFAULT_GOAL := help
33

4-
help: ## Print this message
5-
@echo "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sort | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\x1b[36m\1\x1b[m:\2/' | column -c2 -t -s :)"
6-
.PHONY: help
7-
8-
.revolve-dep:
9-
@python -m pip install -r requirements.txt
10-
.PHONY: .revolve-dep
4+
## --------
5+
##@ Database
6+
## --------
117

128
db-local-apply: .revolve-dep ## Apply database migrations scripts
139
@python -m yoyo --config yoyo-local.ini apply
@@ -22,6 +18,10 @@ db-local-reset: ## Fully reset local db (use Docker)
2218
@make db-local-apply
2319
.PHONY: db-local-reset
2420

21+
## -------
22+
##@ Install
23+
## -------
24+
2525
install: .revolve-dep ## Run locally the application
2626
@rm -rf build dist
2727
@python -m build
@@ -30,3 +30,20 @@ install: .revolve-dep ## Run locally the application
3030

3131
build: .revolve-dep ## Build the application
3232
@python -m build
33+
34+
## ----
35+
##@ Misc
36+
## ----
37+
38+
.revolve-dep:
39+
@python -m pip install -r requirements.txt
40+
.PHONY: .revolve-dep
41+
42+
.DEFAULT_GOAL := help
43+
APPLICATION_TITLE := Astraeus - astraeus-common \n ================
44+
.PHONY: help
45+
# See https://www.thapaliya.com/en/writings/well-documented-makefiles/
46+
help: ## Display this help
47+
@awk 'BEGIN {FS = ":.* ##"; printf "\n\033[32;1m ${APPLICATION_TITLE}\033[0m\n\n\033[1mUsage:\033[0m\n \033[31mmake \033[36m<option>\033[0m\n"} /^[%a-zA-Z_-]+:.* ## / { printf " \033[33m%-25s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' ${MAKEFILE_LIST}
48+
49+
##@

src/astraeus_common/io/db/001_initial_db_creation.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
CREATE TABLE IF NOT EXISTS "astraeus"."system"
1212
(
1313
"key" jsonb PRIMARY KEY,
14-
"name" text,
15-
"coordinates" jsonb,
16-
"require_permit" boolean,
17-
"information" jsonb,
18-
"update_time" timestamp,
19-
"primary_star" jsonb
14+
"name" text,
15+
"coordinates" jsonb,
16+
"require_permit" boolean,
17+
"information" jsonb,
18+
"update_time" timestamp,
19+
"primary_star" jsonb
2020
)
2121
'''
2222
),

src/astraeus_common/io/db/003_add_eddn_messages.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
'''
88
CREATE TABLE IF NOT EXISTS "astraeus"."sync_state"
99
(
10-
"key" jsonb PRIMARY KEY,
11-
"sync_date" timestamp not null,
12-
"type" text not null,
13-
"sync_hash" text,
14-
"previous_state" jsonb
10+
"id" uuid PRIMARY KEY,
11+
"schema" text,
12+
"header" jsonb,
13+
"message" jsonb,
14+
"recv_date" timestamp default null,
15+
"sync_date" timestamp default null
1516
)
1617
'''
1718
)

yoyo-local.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
%inherit = yoyo.ini
88

99
# Target database
10-
database = postgresql://edsm-mirror:edsm-mirror@localhost:5432/edsm-mirror
10+
database = postgresql://astraeus:astraeus@localhost:5432/astraeus-db

0 commit comments

Comments
 (0)