setup: databaseskjema og tilkoblingspool for PostgreSQL (#7) #12
+84
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Beskrivelse
Databaseskjema for Handlelappen i PostgreSQL, basert på funnene fra #6, og en tilkoblingspool backenden kan bruke.
Relaterte issues
Closes #7
Endringer gjort
backend/db/migrations/001_init.sql: tabellene categories, products, prices, shopping_lists og list_items, pg_trgm og indekser på navn (trigram), merke, kategori, labels, pris og store_code. Kan kjøres flere ganger uten feilbackend/src/db.ts: tilkoblingspool som leser DATABASE_URL fra .envbackend/.env.example: databasen heter nåhandlelappAvvik fra issuen
db/migrations/001_init.sql(som under «Ferdig når»), ikkedb/schema.sqldescription,ingredientsoglabelspå products,status,in_use,updated_atogcompleted_atpå shopping_lists,notepå list_itemscategory_id = NULLog vises som «Ukategorisert»Hva slags type fiks inneholder denne PR
Sjekkliste
\dtviser 5 tabeller, pool-tilkobling fungerer)Til reviewer
Installer PostgreSQL og kjør migrasjonen (Mac):
brew install postgresql@17
echo 'export PATH="/opt/homebrew/opt/postgresql@17/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc
brew services start postgresql@17
createdb handlelapp
cd backend && psql handlelapp -f db/migrations/001_init.sql
Sett
DATABASE_URL=postgres://localhost:5432/handlelappi din egen backend/.env.