|
Player12
An open source football management simulator
|
Classes | |
| struct | ColumnSpec |
| class | FutureVersionError |
| struct | Migration |
| struct | MigrationContext |
| struct | MigrationReport |
Functions | |
| std::span< const Migration > | registry () |
| int | currentSchemaVersion () |
| std::string | checksum (const Migration &migration) |
| int | readSchemaVersion (sqlite3 *db) |
| MigrationReport | migrate (const DatabaseConnection &connection, std::span< const Migration > migrations=registry()) |
| bool | tableExists (sqlite3 *db, std::string_view table) |
| bool | columnExists (sqlite3 *db, std::string_view table, std::string_view column) |
| int | foreignKeyIssues (sqlite3 *db) |
Ordered, numbered and transactional schema migrations of a career save.
Every save records the migrations applied to it in schema_migrations and its schema version in save_meta. Opening a save applies the pending migrations in number order, each in one transaction together with its schema_migrations row. See src/database/migrations/README.md for the procedure to add one.
| std::string Migrations::checksum | ( | const Migration & | migration | ) |
Checksum of a migration's declarative content (stored per save).
| bool Migrations::columnExists | ( | sqlite3 * | db, |
| std::string_view | table, | ||
| std::string_view | column | ||
| ) |
True when table exists and has column.
| int Migrations::currentSchemaVersion | ( | ) |
Highest migration number the game knows (the supported save version).
| int Migrations::foreignKeyIssues | ( | sqlite3 * | db | ) |
Foreign key violations, ignoring the free-agents pseudo club (league -1), which is a known sentinel until the sentinel repair migration lands.
| Migrations::MigrationReport Migrations::migrate | ( | const DatabaseConnection & | connection, |
| std::span< const Migration > | migrations = registry() |
||
| ) |
Brings a database to the current schema: rejects future versions before any write, creates missing tables from schema.sql, applies pending migrations in order (one transaction each) and repairs recorded ones whose columns are missing. A failing migration rolls back, leaves the database at the previous version and throws DatabaseException.
| int Migrations::readSchemaVersion | ( | sqlite3 * | db | ) |
Schema version recorded in a database: save_meta.schema_version, or the highest schema_migrations number, or 0 for saves from before versioning. Read-only; works on connections opened with SQLITE_OPEN_READONLY.
| std::span< const Migrations::Migration > Migrations::registry | ( | ) |
Every migration of the game, ordered by number.
| bool Migrations::tableExists | ( | sqlite3 * | db, |
| std::string_view | table | ||
| ) |
True when table exists.