summaryrefslogtreecommitdiff
path: root/migrations/README.md
blob: e849b9c146f4413bc925da80d04307e4ee746bd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Database Migrations

Sequential SQL migrations for task-dashboard schema evolution.

## Migration History

| # | File | Purpose |
|---|------|---------|
| 001 | `001_initial_schema.sql` | Initial schema (tasks, boards, cards, meals) |
| 002 | `002_add_cache_metadata.sql` | Cache metadata table for TTL tracking |
| 003 | `003_add_sync_tokens.sql` | Sync tokens for incremental sync |
| 004 | `004_add_auth.sql` | Authentication (users, sessions) |
| 005 | `005_add_bugs.sql` | Bug tracking table |
| 006 | `006_remove_resolved_bugs.sql` | Add resolved_at timestamp to bugs |
| 007 | — | **SKIPPED** (reserved, never used) |
| 008 | `008_user_shopping_items.sql` | User-added shopping items |
| 009 | `009_shopping_item_checks.sql` | External item check state |
| 010 | `010_agent_tables.sql` | Agent authentication (agents, agent_sessions) |
| 011 | `011_completed_tasks.sql` | Completed tasks log |
| 012 | `012_feature_toggles.sql` | Feature toggle system |
| 013 | `013_source_config.sql` | Source filtering configuration |

## Migration 007 Gap

Migration 007 was reserved during development but never implemented. The gap is intentional and preserved to maintain clean git history. Future migrations continue from 014.

## Running Migrations

Migrations are applied automatically on application startup via `store.RunMigrations()`. The `schema_migrations` table tracks which migrations have been applied.

## Creating New Migrations

1. Create file: `migrations/NNN_description.sql` (next number is 014)
2. Write idempotent SQL (use `IF NOT EXISTS` where possible)
3. Test locally: `go run cmd/dashboard/main.go`
4. Verify: Check `schema_migrations` table for new entry