Skip to content

Commit

Permalink
[native] add table for redux-persist storage
Browse files Browse the repository at this point in the history
Summary: Adding table which is used on web (on native not yet) to make schema consistent.

Test Plan:
1. Run migration and check if table was created.
2. Logout and check if table was created while creating fresh database.

Reviewers: michal, tomek

Reviewed By: michal

Subscribers: ashoat

Differential Revision: https://phab.comm.dev/D8471
  • Loading branch information
xsanm committed Jul 21, 2023
1 parent 3a16499 commit bf8a921
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,15 @@ bool create_reports_table(sqlite3 *db) {
return create_table(db, query, "reports");
}

bool create_persist_storage_table(sqlite3 *db) {
std::string query =
"CREATE TABLE IF NOT EXISTS persist_storage ("
" key TEXT UNIQUE PRIMARY KEY NOT NULL,"
" item TEXT NOT NULL"
");";
return create_table(db, query, "persist_storage");
}

bool create_schema(sqlite3 *db) {
char *error;
sqlite3_exec(
Expand Down Expand Up @@ -459,6 +468,11 @@ bool create_schema(sqlite3 *db) {
" report TEXT NOT NULL"
");"

"CREATE TABLE IF NOT EXISTS persist_storage ("
" key TEXT UNIQUE PRIMARY KEY NOT NULL,"
" item TEXT NOT NULL"
");"

"CREATE INDEX IF NOT EXISTS media_idx_container"
" ON media (container);"

Expand Down Expand Up @@ -697,7 +711,8 @@ std::vector<std::pair<unsigned int, SQLiteMigration>> migrations{
{26, {add_avatar_column_to_threads_table, true}},
{27, {add_pinned_count_column_to_threads, true}},
{28, {create_message_store_threads_table, true}},
{29, {create_reports_table, true}}}};
{29, {create_reports_table, true}},
{30, {create_persist_storage_table, true}}}};

enum class MigrationResult { SUCCESS, FAILURE, NOT_APPLIED };

Expand Down

0 comments on commit bf8a921

Please sign in to comment.