veza/docs/MIGRATIONS.md
senke 43309327e6 feat(v0.501): Sprint 5 -- integration, tests, and cleanup
- INT-01: Add E2E streaming tests (upload -> HLS auth)
- INT-02: Add E2E cloud tests (CRUD auth, public gear)
- INT-03: Split track/handler.go into 4 focused sub-handlers
- INT-04: Create migration squash script + MIGRATIONS.md
- INT-05: Add Trivy container image scanning CI workflow
- INT-06: Replace production console.log with structured logger
2026-02-22 18:40:07 +01:00

44 lines
1.3 KiB
Markdown

# Database Migrations
## Overview
This project uses sequential SQL migration files located in `veza-backend-api/migrations/`.
Migrations are numbered sequentially (001, 002, ..., 108).
## Current State (v0.501)
| Range | Description |
|-------|-------------|
| 001-050 | Core schema (users, tracks, playlists, roles) |
| 051-080 | Features (likes, shares, versions, sessions, OAuth) |
| 081-098 | Advanced (HLS streams, marketplace, notifications) |
| 099-100 | Promo codes and order discounts (v0.402) |
| 101-102 | Previous stabilization migrations |
| 103-108 | v0.501 (waveform, cloud storage, gear images) |
## Running Migrations
Migrations are applied automatically by the backend on startup via GORM AutoMigrate
and manual SQL execution.
## Squash Script
To generate a single baseline SQL file from all migrations:
```bash
./scripts/squash_migrations.sh > veza-backend-api/migrations/baseline_v0501.sql
```
This is useful for:
- Setting up new development environments
- Creating test databases
- Documenting the complete schema
**Important**: Do NOT delete individual migration files. The baseline is supplementary.
## Adding New Migrations
1. Create a new file: `{next_number}_{description}.sql`
2. Use `IF NOT EXISTS` / `IF EXISTS` for idempotency
3. Include a comment header with version reference
4. Test on a clean database before committing