feat: add database layer with schema migrations
Add internal/database package with SQLite3 connection management, versioned migration system, and three schema tables (artist_settings, external_releases, notifications_sent). Includes 7 tests covering initialization, migration idempotency, Close() behavior, and schema validation using in-memory SQLite. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -75,16 +75,16 @@ Build the foundation layer of NaviWatcher: a greenfield Go project with zero exi
|
||||
- [x] run tests — must pass before task 3
|
||||
|
||||
### Task 3: Database layer — schema and migrations
|
||||
- [ ] create `internal/database/database.go` with DB struct and `New(dbPath string) (*DB, error)` constructor
|
||||
- [ ] implement schema migration system (versioned migrations table + ordered migration files or functions)
|
||||
- [ ] create migration 001: `artist_settings` table (id, name, ignore_singles, ignore_compilations, monitored)
|
||||
- [ ] create migration 002: `external_releases` table (rgid PK, artist_id, title, type, release_date, is_ignored)
|
||||
- [ ] create migration 003: `notifications_sent` table (rgid FK, sent_at)
|
||||
- [ ] implement `Close()` method with proper connection cleanup
|
||||
- [ ] write tests for database initialization and schema creation (use in-memory SQLite `:memory:`)
|
||||
- [ ] write tests for migration idempotency (running migrations twice should not fail)
|
||||
- [ ] write tests for Close() behavior
|
||||
- [ ] run tests — must pass before task 4
|
||||
- [x] create `internal/database/database.go` with DB struct and `New(dbPath string) (*DB, error)` constructor
|
||||
- [x] implement schema migration system (versioned migrations table + ordered migration files or functions)
|
||||
- [x] create migration 001: `artist_settings` table (id, name, ignore_singles, ignore_compilations, monitored)
|
||||
- [x] create migration 002: `external_releases` table (rgid PK, artist_id, title, type, release_date, is_ignored)
|
||||
- [x] create migration 003: `notifications_sent` table (rgid FK, sent_at)
|
||||
- [x] implement `Close()` method with proper connection cleanup
|
||||
- [x] write tests for database initialization and schema creation (use in-memory SQLite `:memory:`)
|
||||
- [x] write tests for migration idempotency (running migrations twice should not fail)
|
||||
- [x] write tests for Close() behavior
|
||||
- [x] run tests — must pass before task 4
|
||||
|
||||
### Task 4: Database layer — CRUD operations for artist_settings
|
||||
- [ ] implement `GetArtistSettings(db *DB, id string) (*ArtistSettings, error)`
|
||||
|
||||
Reference in New Issue
Block a user