feat(deploy): update deployment workflow and migration paths
Some checks failed
Deploy to production / deploy (push) Has been cancelled
Some checks failed
Deploy to production / deploy (push) Has been cancelled
- Modified the deployment workflow to include new migration paths for the backend, ensuring that migrations are correctly referenced in the deployment process. - Updated the `db:migrate` script in package.json to point to the `migrations-active` directory, enhancing clarity and organization of migration files. - Adjusted the deployment conditions to account for changes in migration file locations, improving the accuracy of change detection during deployments. - Removed obsolete migration files to streamline the migration process and prevent confusion.
This commit is contained in:
@@ -38,7 +38,7 @@ jobs:
|
||||
echo "force_deploy=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
if grep -E '^(backend/scripts/.*(bisaya|course|didactics|vocab)|backend/sql/.*vocab|backend/migrations/.*vocab|docs/.*(COURSE|VOCAB|BISAYA|GERMAN_FOR_BISAYA))' changed-files.txt; then
|
||||
if grep -E '^(backend/scripts/.*(bisaya|course|didactics|vocab)|backend/sql/.*vocab|backend/(migrations-active|migrations-archive)/.*vocab|docs/.*(COURSE|VOCAB|BISAYA|GERMAN_FOR_BISAYA))' changed-files.txt; then
|
||||
echo "changed=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "changed=false" >> "$GITHUB_OUTPUT"
|
||||
@@ -51,7 +51,7 @@ jobs:
|
||||
fi
|
||||
|
||||
if grep -E '^backend/' changed-files.txt \
|
||||
| grep -Ev '^(backend/scripts/.*(bisaya|course|didactics|vocab)|backend/sql/.*vocab|backend/migrations/.*vocab)$' >/dev/null; then
|
||||
| grep -Ev '^(backend/scripts/.*(bisaya|course|didactics|vocab)|backend/sql/.*vocab|backend/(migrations-active|migrations-archive)/.*vocab)$' >/dev/null; then
|
||||
echo "backend_app_changed=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "backend_app_changed=false" >> "$GITHUB_OUTPUT"
|
||||
@@ -60,7 +60,7 @@ jobs:
|
||||
# App-Code-Änderungen, die einen echten Deploy benötigen
|
||||
# (Frontend oder Backend außerhalb reiner Kurs-/Dokument-Sync-Dateien)
|
||||
if grep -E '^(frontend/|backend/)' changed-files.txt \
|
||||
| grep -Ev '^(backend/scripts/.*(bisaya|course|didactics|vocab)|backend/sql/.*vocab|backend/migrations/.*vocab|docs/.*(COURSE|VOCAB|BISAYA|GERMAN_FOR_BISAYA))'; then
|
||||
| grep -Ev '^(backend/scripts/.*(bisaya|course|didactics|vocab)|backend/sql/.*vocab|backend/(migrations-active|migrations-archive)/.*vocab|docs/.*(COURSE|VOCAB|BISAYA|GERMAN_FOR_BISAYA))'; then
|
||||
echo "app_changed=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "app_changed=false" >> "$GITHUB_OUTPUT"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
This project now supports a per-region sales tax (`tax_percent`) for Falukant.
|
||||
|
||||
Migration
|
||||
- A SQL migration was added: `backend/migrations/20260101000000-add-tax-percent-to-region.cjs`.
|
||||
- A SQL migration was added: `backend/migrations-archive/20260101000000-add-tax-percent-to-region.cjs`.
|
||||
- It adds `tax_percent` numeric NOT NULL DEFAULT 7 to `falukant_data.region`.
|
||||
|
||||
Runtime configuration
|
||||
|
||||
0
backend/migrations-active/.gitkeep
Normal file
0
backend/migrations-active/.gitkeep
Normal file
@@ -1,12 +1,26 @@
|
||||
# Backend-Migrationen (Sequelize)
|
||||
|
||||
Migrationen in diesem Ordner werden mit dem Sequelize-CLI ausgeführt (Konfiguration siehe Projekt-Root / `backend`).
|
||||
## Aktive Migrationen
|
||||
|
||||
Neue Schema-Änderungen: nur noch Dateien unter **`migrations-active/`**. Ausführung z. B.:
|
||||
|
||||
`npm run db:migrate` (siehe `backend/package.json`, Pfad `migrations-active`).
|
||||
|
||||
## Archiv
|
||||
|
||||
Ältere, bereits auf den Umgebungen ausgerollte Migrationen liegen unter **`migrations-archive/`** und werden vom Sequelize-CLI **nicht** mehr ausgeführt.
|
||||
|
||||
Vor dem ersten Deploy nach dieser Aufteilung: fehlende Einträge in `"SequelizeMeta"` für die archivierten Dateinamen per SQL ergänzen, siehe **`sql/baseline-sequelize-meta-migrations-archive.sql`** (idempotent).
|
||||
|
||||
## Sonstiges in diesem Ordner
|
||||
|
||||
SQL-Hilfsdateien und ältere Notizen verbleiben hier (werden nicht vom CLI geladen).
|
||||
|
||||
## Falukant: Zertifikat und Produktionszählung
|
||||
|
||||
| Datei | Inhalt |
|
||||
| Datei (Archiv) | Inhalt |
|
||||
|--------|--------|
|
||||
| `20260402140000-add-certificate-productions-count-since.cjs` | Spalte `falukant_data.falukant_user.certificate_productions_count_since` (`TIMESTAMPTZ`, nullable) inkl. Kommentar. Setzt die DB-Grundlage dafür, dass Daemon, Backend und UI dieselbe Periode für „abgeschlossene Produktionen“ nutzen (Filter mit `COALESCE(production_timestamp, production_date::timestamp)` ab diesem Zeitpunkt; `NULL` = bisherige Historie). |
|
||||
| `migrations-archive/20260402140000-add-certificate-productions-count-since.cjs` | Spalte `falukant_data.falukant_user.certificate_productions_count_since` (`TIMESTAMPTZ`, nullable) inkl. Kommentar. Setzt die DB-Grundlage dafür, dass Daemon, Backend und UI dieselbe Periode für „abgeschlossene Produktionen“ nutzen (Filter mit `COALESCE(production_timestamp, production_date::timestamp)` ab diesem Zeitpunkt; `NULL` = bisherige Historie). |
|
||||
|
||||
Eine parallele SQL-Migration im Daemon-Repository (z. B. `014_falukant_certificate_productions_count_since.sql`) kann dieselbe Spalte anlegen, wenn das Deployment dort getrennt ist – Schema doppelt anlegen vermeiden.
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"dev": "NODE_ENV=development node server.js",
|
||||
"start-daemon": "node daemonServer.js",
|
||||
"sync-db": "node sync-database.js",
|
||||
"db:migrate": "sequelize-cli db:migrate --config config/sequelize-cli.cjs --migrations-path migrations --env production",
|
||||
"db:migrate": "sequelize-cli db:migrate --config config/sequelize-cli.cjs --migrations-path migrations-active --env production",
|
||||
"sync-tables": "node sync-tables-only.js",
|
||||
"check-connections": "node check-connections.js",
|
||||
"cleanup-connections": "node cleanup-connections.js",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- Spalte für tägliches Politik-Gehalt (Sequelize: FalukantUser.lastPoliticalDailySalaryOn).
|
||||
-- Entspricht Migration: backend/migrations/20260401120000-politics-benefits-and-daily-salary.cjs
|
||||
-- Entspricht Migration: backend/migrations-archive/20260401120000-politics-benefits-and-daily-salary.cjs
|
||||
--
|
||||
-- Bevorzugt: Migration per CLI ausführen (führt auch die political_office_benefit-Anpassung aus).
|
||||
-- Nur diese Spalte ohne CLI: dieses Skript einmal ausführen; die Migration nutzt ADD COLUMN IF NOT EXISTS
|
||||
|
||||
80
backend/sql/baseline-sequelize-meta-migrations-archive.sql
Normal file
80
backend/sql/baseline-sequelize-meta-migrations-archive.sql
Normal file
@@ -0,0 +1,80 @@
|
||||
-- Baseline: archivierte Sequelize-Migrationen als „bereits ausgeführt“ markieren
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- Kontext: Ab diesem Stand nutzt `npm run db:migrate` nur noch `migrations-active/`.
|
||||
-- Die bisherigen Dateien liegen unter `migrations-archive/` und werden nicht mehr
|
||||
-- vom CLI ausgeführt. In bestehenden Datenbanken sind viele Einträge in
|
||||
-- "SequelizeMeta" schon vorhanden; fehlende werden hier ergänzt.
|
||||
--
|
||||
-- Wann: Einmal VOR dem ersten Deploy ausführen, der nur noch `migrations-active`
|
||||
-- verwendet (oder direkt nach dem Ausrollen dieses Commits, bevor/neben
|
||||
-- dem nächsten `db:migrate`).
|
||||
--
|
||||
-- Idempotent: Bereits vorhandene Namen werden übersprungen (WHERE NOT EXISTS).
|
||||
--
|
||||
-- Nicht für leere/neue Datenbanken: Dort das Schema über die archivierten
|
||||
-- Migrationen oder euren üblichen Init-Weg aufbauen – diese Baseline ersetzt
|
||||
-- keine fehlenden DDL-Schritte.
|
||||
--
|
||||
-- Wo liegt SequelizeMeta?
|
||||
-- Gleiche PostgreSQL-Datenbank wie das Backend (DB_NAME), in der Regel Schema
|
||||
-- `public`. Sequelize/sequelize-cli legen die Tabelle beim ersten Lauf von
|
||||
-- `db:migrate` an. Fehlt sie, bist du oft in der falschen DB verbunden oder
|
||||
-- es lief noch nie eine Migration gegen diese DB.
|
||||
-- Prüfen: SELECT schemaname, tablename FROM pg_tables
|
||||
-- WHERE tablename IN ('SequelizeMeta','sequelizemeta');
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "SequelizeMeta" (
|
||||
name VARCHAR(255) NOT NULL PRIMARY KEY
|
||||
);
|
||||
|
||||
INSERT INTO "SequelizeMeta" (name)
|
||||
SELECT v.name FROM (VALUES
|
||||
('20240913071145-add-answer-fields-to-contact_message.cjs'),
|
||||
('20251126120000-add-last-nobility-advance-to-falukant-user.cjs'),
|
||||
('20251208000000-add-character-name-to-notification.cjs'),
|
||||
('20251216000000-add-weather-type-to-production.cjs'),
|
||||
('20251216000100-add-product-quality-to-stock.cjs'),
|
||||
('20251220000000-add-reputation-to-character.cjs'),
|
||||
('20251220001000-add-reputation-actions.cjs'),
|
||||
('20251220002000-backfill-reputation-action-window.cjs'),
|
||||
('20251220003000-seed-reputation-actions.cjs'),
|
||||
('20251222000000-fix-vehicle-condition-null.cjs'),
|
||||
('20251222001000-add-may-repair-vehicles-to-director.cjs'),
|
||||
('20251230000000-add-vocab-trainer-tables.cjs'),
|
||||
('20251230001000-add-vocab-chapters-and-lexemes.cjs'),
|
||||
('20260101000000-add-tax-percent-to-region.cjs'),
|
||||
('20260101000002-add-neutral-sell-costs-to-product.cjs'),
|
||||
('20260115000000-add-vocab-courses.cjs'),
|
||||
('20260115000001-add-vocab-grammar-exercises.cjs'),
|
||||
('20260115000002-add-course-structure.cjs'),
|
||||
('20260115000003-add-course-learning-goals.cjs'),
|
||||
('20260118000000-add-notification-user-shown-index.cjs'),
|
||||
('20260320000000-add-relationship-state-and-child-legitimacy.cjs'),
|
||||
('20260320001000-backfill-relationship-state.cjs'),
|
||||
('20260320002000-add-servants-to-user-house.cjs'),
|
||||
('20260323000000-add-household-tension-to-user-house.cjs'),
|
||||
('20260323010000-expand-debtors-prism.cjs'),
|
||||
('20260323020000-add-transport-guards-and-raid-underground.cjs'),
|
||||
('20260325000000-add-vocab-lesson-didactics.cjs'),
|
||||
('20260325010000-expand-user-param-value-to-text.cjs'),
|
||||
('20260326000000-add-adult-area-to-gallery.cjs'),
|
||||
('20260326001000-create-erotic-video.cjs'),
|
||||
('20260326002000-add-is-adult-only-to-chat-room.cjs'),
|
||||
('20260326003000-add-adult-content-moderation.cjs'),
|
||||
('20260327000000-add-erotic-video-visibility.cjs'),
|
||||
('20260330000000-add-character-pregnancy.cjs'),
|
||||
('20260331000000-add-vocab-lesson-phase1-fields.cjs'),
|
||||
('20260401000000-add-vocab-course-progress-lesson-state.cjs'),
|
||||
('20260401120000-politics-benefits-and-daily-salary.cjs'),
|
||||
('20260402120000-add-ui-locale-fr-user-param-value.cjs'),
|
||||
('20260402140000-add-certificate-productions-count-since.cjs'),
|
||||
('20260402180000-political-benefits-mechanics.cjs'),
|
||||
('20260403120000-political-office-hierarchy-level.cjs'),
|
||||
('20260413152500-add-relationship-state-scandal-extra-daily-pct.cjs'),
|
||||
('20260413190000-add-relationship-state-marriage-satisfaction-column.cjs'),
|
||||
('20260417000000-add-vocab-srs-item.cjs'),
|
||||
('add_trigger_for_hashedId.cjs')
|
||||
) AS v(name)
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM "SequelizeMeta" m WHERE m.name = v.name
|
||||
);
|
||||
@@ -38,7 +38,7 @@ Die Datenbasis für Ehezufriedenheit, Liebschaftsstatus und Kinder aus Liebschaf
|
||||
|
||||
- [backend/models/associations.js](/mnt/share/torsten/Programs/YourPart3/backend/models/associations.js)
|
||||
- [backend/models/falukant/data/child_relation.js](/mnt/share/torsten/Programs/YourPart3/backend/models/falukant/data/child_relation.js)
|
||||
- neue Migrationen in [backend/migrations](/mnt/share/torsten/Programs/YourPart3/backend/migrations)
|
||||
- neue Migrationen in [backend/migrations-active](/mnt/share/torsten/Programs/YourPart3/backend/migrations-active)
|
||||
- neue Datei [backend/models/falukant/data/relationship_state.js](/mnt/share/torsten/Programs/YourPart3/backend/models/falukant/data/relationship_state.js)
|
||||
|
||||
### Abhängigkeiten
|
||||
@@ -65,7 +65,7 @@ Bestehende Ehen und Liebschaften mit Startwerten versorgen.
|
||||
|
||||
### Betroffene Dateien
|
||||
|
||||
- neue Migration oder Tool in [backend/migrations](/mnt/share/torsten/Programs/YourPart3/backend/migrations) oder [backend/tools](/mnt/share/torsten/Programs/YourPart3/backend/tools)
|
||||
- neue Migration oder Tool in [backend/migrations-active](/mnt/share/torsten/Programs/YourPart3/backend/migrations-active) oder [backend/tools](/mnt/share/torsten/Programs/YourPart3/backend/tools)
|
||||
- [backend/services/falukantService.js](/mnt/share/torsten/Programs/YourPart3/backend/services/falukantService.js)
|
||||
|
||||
### Abhängigkeiten
|
||||
|
||||
@@ -44,7 +44,7 @@ Die C++-Worker unter **`src/`** sind **[obsolet](LEGACY_CPP_WORKERS.md)** und we
|
||||
|
||||
## Migrationen
|
||||
|
||||
- **Sequelize (dieses Repo):** `backend/migrations/20260402140000-add-certificate-productions-count-since.cjs` – fügt die Spalte und den DB-Kommentar hinzu.
|
||||
- **Sequelize (dieses Repo):** `backend/migrations-archive/20260402140000-add-certificate-productions-count-since.cjs` – fügt die Spalte und den DB-Kommentar hinzu.
|
||||
- **Externer Daemon / SQL-Pfad:** falls vorhanden z. B. `migrations/014_falukant_certificate_productions_count_since.sql` – inhaltlich dieselbe Spalte; nur eine Quelle der Wahrheit fürs Schema nötig.
|
||||
|
||||
Weitere Hinweise: `backend/migrations/README.md`.
|
||||
|
||||
Reference in New Issue
Block a user