Page MenuHomePhabricator

[SQLite] implement `SQLiteSchema` class to wrap creation and migration logic
AcceptedPublic

Authored by kamil on Fri, Apr 11, 8:10 AM.

Details

Reviewers
bartek
tomek
Summary

Moving migration code to new class SQLiteSchema to make managing this easier.

This class is implemented in three .cpp files:

  1. SQLiteSchema.cpp - utils and methods to create/migrate
  2. SQLiteSchemaLegacyMigrations.cpp - old, existing migrations executed from the C++ level only, we should consider this to be read-only now
  3. SQLiteSchemaMigrations.cpp - place where we should add "new" migrations, executed from JS level on a standard migration process or on a backup database after restore.

The API on how to use and execute new migrations will be added later in this stack, publishing this first to get some initial feedback.

I added code comments in SQLiteSchema.h, but if something is unclear, I can clarify.

This code is copied and pasted between places, so there is no need to review the logic itself. I made one change, which is annotated with an inline comment.

The most important part to review here is native/cpp/CommonCpp/DatabaseManagers/SQLiteSchema.h file.

ENG-10540

Depends on D14572

Test Plan
  1. Checkout older commit and build an app, create an account, checkout to this to make sure migration still works.
  2. Log out to check ifthe database creation works.

Diff Detail

Repository
rCOMM Comm
Branch
poc
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

kamil held this revision as a draft.
kamil edited the test plan for this revision. (Show Details)
kamil edited the summary of this revision. (Show Details)
kamil published this revision for review.Fri, Apr 11, 8:29 AM
kamil edited the summary of this revision. (Show Details)
kamil edited the summary of this revision. (Show Details)
kamil edited the summary of this revision. (Show Details)
kamil added inline comments.
native/cpp/CommonCpp/DatabaseManagers/SQLiteSchema.cpp
228–230

The only change is this line to get correct latest version

native/cpp/CommonCpp/DatabaseManagers/SQLiteSchema.h
18

This is type I added

native/cpp/CommonCpp/DatabaseManagers/SQLiteSchemaMigrations.cpp
14

Note: first item here should start with 55 (or anything greater than legacyMigrations)

This revision is now accepted and ready to land.Mon, Apr 14, 1:51 AM
native/cpp/CommonCpp/DatabaseManagers/SQLiteSchemaLegacyMigrations.cpp
826

It might be a good idea to add a comment here saying that new migrations shouldn't be added - instead they should be added to the other file.