Commit d75eb60
Feature/implement internal schema migration (#27)
* feat: Implement internal schema migration system
Adds a comprehensive migration framework for managing pgsqlite's internal schema evolution.
Key features:
- Migration runner with transaction-based execution and automatic rollback
- SHA256 checksum validation for migration integrity
- Migration locking to prevent concurrent migrations
- Support for SQL, SqlBatch, Function, and Combined migration types
- Version tracking in __pgsqlite_metadata table
- Migration history in __pgsqlite_migrations table
Migration behavior:
- NO automatic migrations on startup (safety first)
- Schema version is checked on database initialization
- Throws descriptive error if schema is outdated
- Explicit --migrate CLI flag to run migrations and exit
- Pre-migration databases (v1) are automatically detected
Current migrations:
- v1: Initial schema (creates system tables)
- v2: ENUM support (enum types, values, usage tracking)
Test mode handling:
- In-memory databases auto-migrate during tests
- Detects test environment via CARGO env variable
- All test suites updated and passing
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* docs: Update documentation for schema migration system
Updates documentation to reflect the implemented schema migration behavior:
README.md:
- Added comprehensive Schema Migration section
- Documented explicit --migrate flag requirement
- Included usage examples and error messages
- Explained migration features (transactions, checksums, history)
TODO.md:
- Added note about explicit migration mode in completed tasks
- Confirmed all migration tasks are marked as completed
docs/schema-migration-plan.md:
- Added implementation status header (COMPLETED)
- Updated Migration Execution Timing section
- Changed from automatic to explicit migration approach
- Added example commands showing migration workflow
The documentation now clearly explains that migrations are never run
automatically (except for test in-memory databases) and users must
explicitly use the --migrate flag for safety.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: Add migration step to integration test script for file databases
The GitHub Actions integration tests were failing because file-based
database tests need to run migrations before starting the server.
Changes:
- Add migration execution for file-ssl and file-no-ssl modes
- Run `pgsqlite --migrate` before starting the server
- Ensure test database cleanup includes file databases
- Exit with error if migration fails
This fixes the CI/CD pipeline failure where tests failed with:
"Database schema is outdated. Current version: 0, Required version: 2"
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: Enable auto-migration for in-memory databases in integration tests
GitHub Actions was failing because in-memory databases weren't
auto-migrating in the release build used by integration tests.
Changes:
- Add PGSQLITE_TEST_AUTO_MIGRATE environment variable support
- In-memory databases auto-migrate when this env var is set
- Test script sets this for in-memory test modes (tcp-ssl, tcp-no-ssl, unix-socket)
- File-based test modes continue to use explicit --migrate
This allows integration tests to run successfully while maintaining
the safety of explicit migrations in production.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 63b158a commit d75eb60
File tree
20 files changed
+2545
-0
lines changed- docs
- src
- migration
- session
- tests
20 files changed
+2545
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
42 | 72 | | |
43 | 73 | | |
44 | 74 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
61 | 64 | | |
62 | 65 | | |
63 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
240 | 271 | | |
241 | 272 | | |
242 | 273 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
218 | 236 | | |
219 | 237 | | |
220 | 238 | | |
| |||
0 commit comments