Skip to content

feat(db): add SQLite migration SQL generation - #2

Open
Fhatu12 wants to merge 1 commit into
vixcpp:devfrom
Fhatu12:feat/sqlite-migration-generator
Open

feat(db): add SQLite migration SQL generation#2
Fhatu12 wants to merge 1 commit into
vixcpp:devfrom
Fhatu12:feat/sqlite-migration-generator

Conversation

@Fhatu12

@Fhatu12 Fhatu12 commented Aug 23, 2026

Copy link
Copy Markdown

Problem

SQLite is accepted by the migration CLI, but makemigrations --dialect sqlite had no SQL generator behind it.

Implementation

  • Added a SQLite generator for the existing portable migration operations: create/drop table, add/drop column, create/drop index, and down migrations.
  • Mapped portable schema types to SQLite affinity-appropriate DDL and quoted identifiers with escaped embedded double quotes.
  • Added explicit diagnostics for unsupported SQLite ADD COLUMN forms before migration files are written.
  • Routed makemigrations --dialect sqlite through the new generator while preserving MySQL as the default.
  • Made diff ordering deterministic for stable migration output.

Executable proof

Generated SQLite migrations are executed against temporary in-memory SQLite databases in vix_db_sql_generator_tests; the tests assert table/column/index metadata, unique-index enforcement, drop behavior, and down-migration recovery for reversible operations.

Validation

  • Rootless CMake/Ninja: CMake 4.4.2 and Ninja 1.13.0 from /tmp/vix-cmake-venv; no sudo/global install.
  • Rootless deps: extracted Ubuntu packages under /tmp/vix-sqlite-dev.1I4RDT/extract/usr for SQLite, nlohmann_json, fmt, and spdlog.
  • Configure: cmake -S . -B /tmp/vix-db-pr2-build.Z1AZof -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DVIX_DB_BUILD_TESTS=ON -DVIX_DB_BUILD_EXAMPLES=OFF -DVIX_DB_BUILD_TOOLS=ON -DVIX_DB_USE_MYSQL=OFF -DVIX_DB_USE_SQLITE=ON -DVIX_DB_REQUIRE_SQLITE=ON ...
  • Build: cmake --build /tmp/vix-db-pr2-build.Z1AZof --parallel passed; built libvix_db.a, vix_db_sql_generator_tests, and vix_db_migrator.
  • CTest: ctest --test-dir /tmp/vix-db-pr2-build.Z1AZof --output-on-failure passed 10/10, including vix_db_sql_generator_tests.
  • Direct test: /tmp/vix-db-pr2-build.Z1AZof/vix_db_sql_generator_tests -> vix_db_sql_generator_tests passed.
  • Install: cmake --install /tmp/vix-db-pr2-build.Z1AZof --prefix /tmp/vix-db-pr2-install.E5tKsS passed. Installed include/vix/db/mig/sql/MySqlGenerator.hpp, include/vix/db/mig/sql/SQLiteGenerator.hpp, lib/libvix_db.a, and libexec/vix/vix_db_migrator.
  • External consumer: compiled and ran a tiny out-of-tree program against the installed SQLiteGenerator.hpp and libvix_db.a.
  • Deterministic ordering: repeated the same schema diff + SQLite generation 20 times and confirmed identical SQL order.
  • Static analysis: cppcheck and clang-tidy are not installed locally; no new tooling added for this pass.

Configure also confirms SQLite requested/detected ON and MySQL requested/detected OFF. The only configure warning is an upstream CMake author warning that SQLite::SQLite3 is deprecated in favor of SQLite3::SQLite3.

Compatibility

Existing MySQL generation is covered by a regression golden test inside vix_db_sql_generator_tests; MySQL remains the default dialect and no live MySQL server is required.

AI disclosure

OpenAI Codex assisted with codebase analysis, implementation, and validation. I reviewed the changes and take responsibility for the contribution.

Closes vixcpp/vix#460

Notes

This is module-first for vixcpp/db; the umbrella submodule pointer should be updated after this module commit is available upstream.

@Fhatu12 Fhatu12 changed the title Add SQLite migration SQL generator feat(db): add SQLite migration SQL generation Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant