Loading editor/src/webedit_db.cpp +35 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,41 @@ void webedit::Database::initTables() { dbpp::SQL sql; dbpp::DBResult res; // --- Migration: drop old tables missing owner_uid/domain columns --- // Check if connections table exists but lacks owner_uid column try { sql << "SELECT owner_uid FROM connections LIMIT 1;"; _db->exec(sql, res); } catch (...) { // Column doesn't exist — drop the old table sql.clear(); res.clear(); try { sql << "DROP TABLE IF EXISTS connections;"; _db->exec(sql, res); } catch (...) {} } sql.clear(); res.clear(); // Check if documents table exists but lacks owner_uid column try { sql << "SELECT owner_uid FROM documents LIMIT 1;"; _db->exec(sql, res); } catch (...) { // Column doesn't exist — drop old tables (revisions depend on documents) sql.clear(); res.clear(); try { sql << "DROP TABLE IF EXISTS document_revisions;"; _db->exec(sql, res); } catch (...) {} sql.clear(); res.clear(); try { sql << "DROP TABLE IF EXISTS documents;"; _db->exec(sql, res); } catch (...) {} } sql.clear(); res.clear(); // --- Create tables --- sql << "CREATE TABLE IF NOT EXISTS documents(" << "id " << _db->getUUIDType(sql) << "," << "owner_uid text NOT NULL," Loading Loading
editor/src/webedit_db.cpp +35 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,41 @@ void webedit::Database::initTables() { dbpp::SQL sql; dbpp::DBResult res; // --- Migration: drop old tables missing owner_uid/domain columns --- // Check if connections table exists but lacks owner_uid column try { sql << "SELECT owner_uid FROM connections LIMIT 1;"; _db->exec(sql, res); } catch (...) { // Column doesn't exist — drop the old table sql.clear(); res.clear(); try { sql << "DROP TABLE IF EXISTS connections;"; _db->exec(sql, res); } catch (...) {} } sql.clear(); res.clear(); // Check if documents table exists but lacks owner_uid column try { sql << "SELECT owner_uid FROM documents LIMIT 1;"; _db->exec(sql, res); } catch (...) { // Column doesn't exist — drop old tables (revisions depend on documents) sql.clear(); res.clear(); try { sql << "DROP TABLE IF EXISTS document_revisions;"; _db->exec(sql, res); } catch (...) {} sql.clear(); res.clear(); try { sql << "DROP TABLE IF EXISTS documents;"; _db->exec(sql, res); } catch (...) {} } sql.clear(); res.clear(); // --- Create tables --- sql << "CREATE TABLE IF NOT EXISTS documents(" << "id " << _db->getUUIDType(sql) << "," << "owner_uid text NOT NULL," Loading