Check column existence in MigrateFrom3to4 and fix incorrect test database dump data (#29362)
This commit is contained in:
@@ -74,6 +74,18 @@ bool MigrateFrom2To3(sql::Database* db) {
|
||||
}
|
||||
|
||||
bool MigrateFrom3to4(sql::Database* db) {
|
||||
// Check if column exists first
|
||||
static constexpr char kCheckColumnQuery[] =
|
||||
"PRAGMA table_info(conversation_entry_uploaded_files)";
|
||||
sql::Statement check_statement(db->GetUniqueStatement(kCheckColumnQuery));
|
||||
|
||||
while (check_statement.Step()) {
|
||||
if (check_statement.ColumnString(1) == "type") {
|
||||
// Column already exists, no need to migrate
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static constexpr char kAddTypeColumnQuery[] =
|
||||
"ALTER TABLE conversation_entry_uploaded_files ADD COLUMN type INTEGER "
|
||||
"DEFAULT 0";
|
||||
|
||||
@@ -16,5 +16,4 @@ INSERT INTO conversation_entry VALUES('f761af26-4491-4787-ad53-82238b42f534','1a
|
||||
CREATE TABLE conversation_entry_event_completion(conversation_entry_uuid INTEGER NOT NULL,event_order INTEGER NOT NULL,text BLOB NOT NULL,PRIMARY KEY(conversation_entry_uuid, event_order));
|
||||
INSERT INTO conversation_entry_event_completion VALUES('f761af26-4491-4787-ad53-82238b42f534',0,X'76313080a3088aa5874d731e9b5042cb565dab897e3af6560681aad24ef9c9379de805096188372c73372de010da70dd9231cfd70490087fd074004e3c826852cb400903a589baf91e4b3ad75acfe8b40b2bc6846b9c00edd6a3d32359c98614383d35');
|
||||
CREATE TABLE conversation_entry_event_search_queries(conversation_entry_uuid INTEGER NOT NULL,event_order INTEGER NOT NULL,queries BLOB NOT NULL,PRIMARY KEY(conversation_entry_uuid, event_order));
|
||||
CREATE TABLE conversation_entry_uploaded_files(conversation_entry_uuid INTEGER NOT NULL,file_order INTEGER NOT NULL,filename BLOB NOT NULL,filesize INTEGER NOT NULL,data BLOB NOT NULL,PRIMARY KEY(conversation_entry_uuid, file_order));
|
||||
COMMIT;
|
||||
|
||||
@@ -16,5 +16,4 @@ INSERT INTO conversation_entry VALUES('f761af26-4491-4787-ad53-82238b42f534','1a
|
||||
CREATE TABLE conversation_entry_event_completion(conversation_entry_uuid INTEGER NOT NULL,event_order INTEGER NOT NULL,text BLOB NOT NULL,PRIMARY KEY(conversation_entry_uuid, event_order));
|
||||
INSERT INTO conversation_entry_event_completion VALUES('f761af26-4491-4787-ad53-82238b42f534',0,X'76313080a3088aa5874d731e9b5042cb565dab897e3af6560681aad24ef9c9379de805096188372c73372de010da70dd9231cfd70490087fd074004e3c826852cb400903a589baf91e4b3ad75acfe8b40b2bc6846b9c00edd6a3d32359c98614383d35');
|
||||
CREATE TABLE conversation_entry_event_search_queries(conversation_entry_uuid INTEGER NOT NULL,event_order INTEGER NOT NULL,queries BLOB NOT NULL,PRIMARY KEY(conversation_entry_uuid, event_order));
|
||||
CREATE TABLE conversation_entry_uploaded_files(conversation_entry_uuid INTEGER NOT NULL,file_order INTEGER NOT NULL,filename BLOB NOT NULL,filesize INTEGER NOT NULL,data BLOB NOT NULL,PRIMARY KEY(conversation_entry_uuid, file_order));
|
||||
COMMIT;
|
||||
|
||||
Reference in New Issue
Block a user