|
| 1 | +# SharpCoreDB Roadmap |
| 2 | + |
| 3 | +## 1) Read-only instances and schema changes |
| 4 | + |
| 5 | +- Problem |
| 6 | + - A read-only database instance loads the metadata (tables/indexes) once during construction. |
| 7 | + - New tables created later by a read-write instance are invisible to already opened read-only instances. |
| 8 | + - Result: queries against newly created tables fail on those read-only instances until they are recreated. |
| 9 | + |
| 10 | +- Current guidance (to document in guides/demos) |
| 11 | + - Open read-only instances after completing schema changes; or |
| 12 | + - Dispose and recreate read-only instances after CREATE/ALTER; or |
| 13 | + - Run reporting/read-only processes that restart on schema changes. |
| 14 | + |
| 15 | +- Plan (non-breaking; v1.1.x) |
| 16 | + 1. API: `IDatabase.ReloadMetadata()` |
| 17 | + - Forces a reload of `meta.json` and rebinds in-memory tables/indexes. |
| 18 | + - Allowed for read-only instances (no write locks needed). |
| 19 | + 2. Opt-in auto-refresh for read-only |
| 20 | + - `DatabaseConfig` flag: `AutoReloadMetadataOnChange` (default: false). |
| 21 | + - File watcher on `meta.json` → debounce → `ReloadMetadata()`. |
| 22 | + 3. Schema versioning |
| 23 | + - Extend meta with `SchemaVersion` (monotonic counter). |
| 24 | + - Validate at query start: mismatch → (optional) auto-reload when the flag is active. |
| 25 | + 4. Events |
| 26 | + - Read-write: `OnSchemaChanged` after `CREATE/DROP/ALTER` (increments `SchemaVersion`). |
| 27 | + 5. Connection pool integration |
| 28 | + - Invalidate/refresh read-only pooled instances on schema changes (when pooling is enabled). |
| 29 | + |
| 30 | +- Testing |
| 31 | + - Unit: `ReloadMetadata` reflects a newly created table; existing queries keep working. |
| 32 | + - Integration: Read-write → CREATE TABLE; read-only with AutoReload flag sees the new table without recreation. |
| 33 | + |
| 34 | +- Documentation |
| 35 | + - Add a section in `docs/guides/EXAMPLES.md`: timing of read-only instances, `ReloadMetadata()` usage, and the opt-in auto-reload flag. |
| 36 | + |
| 37 | +- Expected impact |
| 38 | + - Backwards compatible; no breaking changes. |
| 39 | + - Minimal runtime overhead when auto-reload is disabled (default). |
| 40 | + |
| 41 | +- Target versions |
| 42 | + - v1.1.0: API + docs |
| 43 | + - v1.1.1: opt-in auto-reload + tests |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | +## 2) Users & permissions demo (completed) |
| 48 | +- Demo shows: |
| 49 | + - Two users (`writer`, `reader`) and two connections (RW/RO). |
| 50 | + - RW performs schema and data mutations; RO performs selects and blocks writes. |
| 51 | + - Included in `SharpCoreDB.Demo` and referenced from docs. |
| 52 | + |
| 53 | +--- |
| 54 | + |
| 55 | +## 3) Quality-of-life improvements |
| 56 | +- More specific exception for write attempts on read-only connections (include hint to recreate or reload). |
| 57 | +- `IDatabaseInfo` surface: `IsReadOnly`, `SchemaVersion`, `Tables` (for diagnostics/telemetry). |
| 58 | + |
| 59 | +--- |
| 60 | + |
| 61 | +## Git compliance |
| 62 | +- Follow Conventional Commits for changes related to this roadmap: |
| 63 | + - `feat(db): add ReloadMetadata API to refresh catalog on read-only instances` |
| 64 | + - `feat(config): add AutoReloadMetadataOnChange flag` |
| 65 | + - `docs(guide): document read-only behavior and metadata reload` |
| 66 | + - `test(db): add integration tests for metadata reload` |
| 67 | +- Ensure updates include unit/integration tests and documentation changes in the same PR when feasible. |
| 68 | + |
0 commit comments