mirror of
https://github.com/bybrooklyn/alchemist.git
synced 2026-04-18 09:53:33 -04:00
1.5 KiB
1.5 KiB
Database Migration Policy
Baseline Version: 0.2.5
All database migrations from this point forward MUST maintain backwards compatibility with the v0.2.5 schema.
Rules for Future Migrations
✅ ALLOWED
- Add new tables - Use
CREATE TABLE IF NOT EXISTS - Add new columns - Must be
NULLable OR have aDEFAULTvalue - Add new indexes - Use
CREATE INDEX IF NOT EXISTS - Insert new rows - Use
INSERT OR IGNORE/INSERT OR REPLACE
❌ FORBIDDEN
- Never remove columns - Old data must remain accessible
- Never rename columns - Create new column + migrate data if needed
- Never change column types - Add a new column instead
- Never remove tables - Mark as deprecated in comments instead
- Never add NOT NULL columns without defaults
- Never modify existing migration files - Once a migration is applied, it is immutable. Changing it breaks database integrity checksums. Creates a NEW migration file for any changes.
Schema Version Tracking
The schema_info table tracks:
schema_version- Integer version of the schema (increments with each migration)min_compatible_version- Minimum app version that can read this DB
Migration Naming Convention
YYYYMMDDHHMMSS_description.sql
Example: 20260109210000_add_notifications_table.sql
Testing Migrations
Before releasing any migration:
- Test upgrading from v0.2.5 database
- Verify all existing queries still work
- Verify new features work with fresh DB
- Verify new features gracefully handle missing data in old DBs