|
cwist
Modern C web framework with libttak runtime
|
Schema migration helpers for applying and rolling back ordered SQL revisions. More...

Go to the source code of this file.
Functions | |
| int | cwist_migrate_version (sqlite3 *db) |
| Query the highest applied migration version recorded in the database. | |
| int | cwist_migrate_up (sqlite3 *db, const cwist_migration_t *migrations, int count) |
| Apply all pending up migrations after sorting them by version. | |
| int | cwist_migrate_down (sqlite3 *db, const cwist_migration_t *migrations, int count, int steps) |
| Roll back applied migrations in reverse version order. | |
Schema migration helpers for applying and rolling back ordered SQL revisions.
Definition in file migrate.c.
Roll back applied migrations in reverse version order.
Roll back the most recent steps migrations.
| db | SQLite connection to migrate. |
| migrations | Caller-supplied migration array. |
| count | Number of entries in migrations. |
| steps | Maximum number of applied versions to roll back, or all when <= 0. |
Definition at line 174 of file migrate.c.
References count, CWIST_MIGRATE_ERR_ARGS, CWIST_MIGRATE_ERR_GENERIC, CWIST_MIGRATE_ERR_SQL, CWIST_MIGRATE_OK, and cwist_migrate_version().
| int cwist_migrate_up | ( | sqlite3 * | db, |
| const cwist_migration_t * | migrations, | ||
| int | count | ||
| ) |
Apply all pending up migrations after sorting them by version.
Apply all migrations whose version > current schema version.
| db | SQLite connection to migrate. |
| migrations | Caller-supplied migration array. |
| count | Number of entries in migrations. |
Definition at line 123 of file migrate.c.
References count, CWIST_MIGRATE_ERR_ARGS, CWIST_MIGRATE_ERR_GENERIC, CWIST_MIGRATE_ERR_SQL, CWIST_MIGRATE_OK, and cwist_migrate_version().
Query the highest applied migration version recorded in the database.
Return the highest version number that has been applied.
| db | SQLite connection to inspect. |
Definition at line 99 of file migrate.c.
References CWIST_MIGRATE_OK.
Referenced by cwist_migrate_down(), and cwist_migrate_up().