Expand description
Schema definition and migration system. SQL schema definitions and migrations.
This module contains the database schema used by SQL backends. The schema is designed to be portable between SQLite and Postgres.
§Migration System
The migration system uses code-based migrations rather than SQL files to handle dialect differences between SQLite and PostgreSQL. Each migration is a function that receives the backend and can execute database-specific SQL as needed.
§Adding a New Migration
- Increment
SCHEMA_VERSION - Add a new
migrate_vN_to_vMasync function - Add the migration to the match statement in
run_migration - Document what the migration does
Constants§
- CREATE_
INDEXES - SQL statements to create indexes.
- CREATE_
TABLES - SQL statements to create the schema tables.
- SCHEMA_
VERSION - Current schema version.
Functions§
- initialize
- Initialize the database schema.