diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp --- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp +++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp @@ -3,6 +3,7 @@ #include "sqlite_orm.h" #include "entities/Media.h" +#include "entities/Metadata.h" #include #include #include @@ -243,6 +244,14 @@ return false; } +bool create_metadata_table(sqlite3 *db) { + std::string query = + "CREATE TABLE IF NOT EXISTS metadata ( " + "name TEXT UNIQUE PRIMARY KEY NOT NULL, " + "data TEXT);"; + return create_table(db, query, "metadata"); +} + void set_encryption_key(sqlite3 *db) { std::string set_encryption_key_query = "PRAGMA key = \"x'" + SQLiteQueryExecutor::encryptionKey + "'\";"; @@ -383,7 +392,8 @@ {19, {create_media_idx_container, true}}, {20, {create_threads_table, true}}, {21, {update_threadID_for_pending_threads_in_drafts, true}}, - {22, {enable_write_ahead_logging_mode, false}}}}; + {22, {enable_write_ahead_logging_mode, false}}, + {23, {create_metadata_table, true}}}}; void SQLiteQueryExecutor::migrate() { validate_encryption(); @@ -492,7 +502,11 @@ make_column("roles", &Thread::roles), make_column("current_user", &Thread::current_user), make_column("source_message_id", &Thread::source_message_id), - make_column("replies_count", &Thread::replies_count))); + make_column("replies_count", &Thread::replies_count)), + make_table( + "metadata", + make_column("name", &Metadata::name, unique(), primary_key()), + make_column("data", &Metadata::data))); storage.on_open = set_encryption_key; return storage; } diff --git a/native/cpp/CommonCpp/DatabaseManagers/entities/Metadata.h b/native/cpp/CommonCpp/DatabaseManagers/entities/Metadata.h new file mode 100644 --- /dev/null +++ b/native/cpp/CommonCpp/DatabaseManagers/entities/Metadata.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace comm { + +struct Metadata { + std::string name; + std::string data; +}; + +} // namespace comm diff --git a/native/ios/Comm.xcodeproj/project.pbxproj b/native/ios/Comm.xcodeproj/project.pbxproj --- a/native/ios/Comm.xcodeproj/project.pbxproj +++ b/native/ios/Comm.xcodeproj/project.pbxproj @@ -62,6 +62,7 @@ 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = Comm/main.m; sourceTree = ""; }; 2DDA00CA889DFF0ECB7E338D /* ClientGetReadReactor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClientGetReadReactor.cpp; sourceTree = ""; }; 2DDA05D6D8D20D885F22F82C /* SocketStatus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocketStatus.h; sourceTree = ""; }; + 2DDA0A22FECC9DAA5C19C35D /* Metadata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Metadata.h; sourceTree = ""; }; 71009A7326FDCA67002C8453 /* tunnelbroker.pb.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tunnelbroker.pb.cc; sourceTree = ""; }; 71009A7426FDCA67002C8453 /* tunnelbroker.pb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tunnelbroker.pb.h; sourceTree = ""; }; 71009A7526FDCA67002C8453 /* tunnelbroker.grpc.pb.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tunnelbroker.grpc.pb.cc; sourceTree = ""; }; @@ -301,6 +302,7 @@ 71BE84452636A944002849D2 /* Draft.h */, B70FBC1226B047050040F480 /* Message.h */, B7E937CA26F448E700022A7C /* Media.h */, + 2DDA0A22FECC9DAA5C19C35D /* Metadata.h */, ); path = entities; sourceTree = "";