Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf0f1af649 | ||
|
|
5e4120a027 | ||
|
|
e14aa0fea6 | ||
|
|
b6f2ac06ae |
@@ -1,5 +1,6 @@
|
|||||||
# -include: silently skip if .env doesn't exist (e.g. fresh clone before 'cp .env.example .env')
|
# -include: silently skip if .env doesn't exist (e.g. fresh clone before 'cp .env.example .env')
|
||||||
-include .env
|
-include .env
|
||||||
|
-include backend/.env
|
||||||
export
|
export
|
||||||
|
|
||||||
.PHONY: dev-db migrate-up migrate-down run-backend run-frontend test fmt
|
.PHONY: dev-db migrate-up migrate-down run-backend run-frontend test fmt
|
||||||
|
|||||||
@@ -17,13 +17,43 @@ A full-stack fruit-variety database (Go + Vue 3).
|
|||||||
cp .env.example .env # set credentials
|
cp .env.example .env # set credentials
|
||||||
cp backend/.env.example backend/.env # set JWT_SECRET and USERS_FILE
|
cp backend/.env.example backend/.env # set JWT_SECRET and USERS_FILE
|
||||||
cp users.env.example users.env # create user file (see below)
|
cp users.env.example users.env # create user file (see below)
|
||||||
./scripts/create_user.sh admin secret >> users.env # add a user
|
./scripts/create_user.sh admin secret >> users.env # add a user (restart backend to reload)
|
||||||
make dev-db # start Postgres (waits until healthy)
|
make dev-db # start Postgres (waits until healthy)
|
||||||
make migrate-up # apply schema migrations
|
make migrate-up # apply schema migrations
|
||||||
make run-backend # Echo API on :3000
|
make run-backend # Echo API on :3000
|
||||||
make run-frontend # Vite dev server on :5000
|
make run-frontend # Vite dev server on :5000
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Importing Legacy Data
|
||||||
|
|
||||||
|
Prerequisites: Postgres running and migrated, `psycopg2` installed (`pip install psycopg2-binary`), `03-data/` present at repo root.
|
||||||
|
|
||||||
|
Scripts must be run in order — publications depend on fruits being present.
|
||||||
|
|
||||||
|
### 1. Import fruits
|
||||||
|
|
||||||
|
```bash
|
||||||
|
DATABASE_URL=postgres://osdb:osdb@localhost:5432/osdb?sslmode=disable python3 scripts/import_fruits.py
|
||||||
|
```
|
||||||
|
|
||||||
|
Imports fruits, synonyms, and fruit images from `03-data/obstsorten.xml`. Idempotent: upserts by `osdb_number`.
|
||||||
|
|
||||||
|
### 2. Import publications
|
||||||
|
|
||||||
|
```bash
|
||||||
|
DATABASE_URL=postgres://osdb:osdb@localhost:5432/osdb?sslmode=disable python3 scripts/import_publications.py
|
||||||
|
```
|
||||||
|
|
||||||
|
Imports publications from `03-data/osws.xml`. For each publication: upserts the row, loads cover image, links fruits, and imports PDFs and fruit images. Idempotent: clears and re-inserts linked data on re-run.
|
||||||
|
|
||||||
|
## Managing Users
|
||||||
|
|
||||||
|
Add a user and restart the backend to reload:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./scripts/create_user.sh <username> <password> >> users.env
|
||||||
|
```
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
DATABASE_URL=postgres://osdb:osdb@localhost:5432/osdb
|
DATABASE_URL=postgres://osdb:osdb@localhost:5432/osdb?sslmode=disable
|
||||||
PORT=3000
|
PORT=3000
|
||||||
JWT_SECRET=change-me-use-a-long-random-string
|
JWT_SECRET=change-me-use-a-long-random-string
|
||||||
USERS_FILE=../users.env
|
USERS_FILE=../users.env
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
# Import Scripts
|
|
||||||
|
|
||||||
## Prerequisites
|
|
||||||
|
|
||||||
- Postgres running and migrated (`make migrate-up`)
|
|
||||||
- `DATABASE_URL` set, e.g.:
|
|
||||||
```
|
|
||||||
export DATABASE_URL=postgres://user:pass@localhost:5432/osdb
|
|
||||||
```
|
|
||||||
- `03-data/` directory present at repo root
|
|
||||||
- `psycopg2` installed (`pip install psycopg2-binary`)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Run Order
|
|
||||||
|
|
||||||
Scripts must be run in order — publications import depends on fruits being present.
|
|
||||||
|
|
||||||
### 1. Import fruits
|
|
||||||
|
|
||||||
```bash
|
|
||||||
DATABASE_URL=... python3 scripts/import_fruits.py
|
|
||||||
```
|
|
||||||
|
|
||||||
Imports fruits, synonyms, and fruit images from `03-data/obstsorten.xml`.
|
|
||||||
Idempotent: upserts fruits by `osdb_number`.
|
|
||||||
|
|
||||||
### 2. Import publications
|
|
||||||
|
|
||||||
```bash
|
|
||||||
DATABASE_URL=... python3 scripts/import_publications.py
|
|
||||||
```
|
|
||||||
|
|
||||||
Imports publications from `03-data/osws.xml` (only `<obj>` elements with `<osw>=1`).
|
|
||||||
For each publication: upserts the row, loads cover image, links fruits found by
|
|
||||||
filesystem scan of `03-data/osdb/{pubId}/`, and imports PDFs and fruit images.
|
|
||||||
Idempotent: clears and re-inserts linked data on re-run.
|
|
||||||
@@ -51,7 +51,10 @@ TYP_MAP = {
|
|||||||
|
|
||||||
IMAGE_DIRS = [
|
IMAGE_DIRS = [
|
||||||
("einzelfruechte", "fruit"),
|
("einzelfruechte", "fruit"),
|
||||||
|
("osdb/fru", "fruit"),
|
||||||
|
("osdb/frucht", "fruit"),
|
||||||
("blueten", "flower"),
|
("blueten", "flower"),
|
||||||
|
("osdb/blu", "flower"),
|
||||||
("baume", "tree"),
|
("baume", "tree"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user