Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33307857
D5146.1768799950.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D5146.1768799950.diff
View Options
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
@@ -289,6 +289,34 @@
return false;
}
+bool add_not_null_constraint_to_metadata(sqlite3 *db) {
+ char *error;
+ sqlite3_exec(
+ db,
+ "CREATE TABLE IF NOT EXISTS temporary_metadata ("
+ "name TEXT UNIQUE PRIMARY KEY NOT NULL, "
+ "data TEXT NOT NULL);"
+ "INSERT INTO temporary_metadata SELECT * FROM metadata "
+ "WHERE data IS NOT NULL;"
+ "DROP TABLE metadata;"
+ "ALTER TABLE temporary_metadata RENAME TO metadata;",
+ nullptr,
+ nullptr,
+ &error);
+
+ if (!error) {
+ return true;
+ }
+
+ std::ostringstream stringStream;
+ stringStream << "Error adding NOT NULL constraint to metadata table: "
+ << error;
+ Logger::log(stringStream.str());
+
+ sqlite3_free(error);
+ return false;
+}
+
void set_encryption_key(sqlite3 *db) {
std::string set_encryption_key_query =
"PRAGMA key = \"x'" + SQLiteQueryExecutor::encryptionKey + "'\";";
@@ -482,7 +510,8 @@
{21, {update_threadID_for_pending_threads_in_drafts, true}},
{22, {enable_write_ahead_logging_mode, false}},
{23, {create_metadata_table, true}},
- {24, {add_not_null_constraint_to_drafts, true}}}};
+ {24, {add_not_null_constraint_to_drafts, true}},
+ {25, {add_not_null_constraint_to_metadata, true}}}};
void SQLiteQueryExecutor::migrate() const {
validate_encryption();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 19, 5:19 AM (13 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5954535
Default Alt Text
D5146.1768799950.diff (1 KB)
Attached To
Mode
D5146: [native/sqlite] add `NOT NULL` constraint to `metadata` table
Attached
Detach File
Event Timeline
Log In to Comment