From bf8a92185308344a77ec7c73e8b2136bdc02faca Mon Sep 17 00:00:00 2001 From: xsanm Date: Fri, 7 Jul 2023 15:03:46 +0200 Subject: [PATCH] [native] add table for redux-persist storage 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 --- .../DatabaseManagers/SQLiteQueryExecutor.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp index 6ce861518f..0a5cd60517 100644 --- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp +++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp @@ -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( @@ -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);" @@ -697,7 +711,8 @@ std::vector> 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 };