Development Documentation (main branch) - For stable release docs, see docs.rs/eidetica

Module schema

Module schema 

Source
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

  1. Increment SCHEMA_VERSION
  2. Add a new migrate_vN_to_vM async function
  3. Add the migration to the match statement in run_migration
  4. 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.