Add database migration for user flags and video publish date

This commit is contained in:
Daniel Schulte 2021-07-18 16:41:36 +02:00
parent 2d1e42ea33
commit 8e7ea28da6
1 changed files with 13 additions and 0 deletions

13
db.cpp
View File

@ -78,6 +78,19 @@ CREATE TABLE videos (
INSERT INTO settings(key, value) VALUES("schema_version", "1"); )"; INSERT INTO settings(key, value) VALUES("schema_version", "1"); )";
SC(sqlite3_exec(db, db_init_sql.c_str(), nullptr, nullptr, nullptr)); SC(sqlite3_exec(db, db_init_sql.c_str(), nullptr, nullptr, nullptr));
} }
if(schema_version < 2) {
const std::string sql = R"(
ALTER TABLE channels ADD COLUMN user_flags INTEGER DEFAULT 0;
CREATE TABLE user_flags (
flagId INTEGER PRIMARY KEY,
name TEXT NOT NULL
);
ALTER TABLE videos ADD COLUMN added_to_playlist TEXT;
UPDATE videos SET added_to_playlist = published, published = "";
UPDATE settings SET value="2" WHERE key="schema_version";
)";
SC(sqlite3_exec(db, sql.c_str(), nullptr, nullptr, nullptr));
}
} }
std::string db_get_setting(const std::string &key) std::string db_get_setting(const std::string &key)