mirror of
https://github.com/YACReader/yacreader
synced 2026-01-30 11:53:32 -05:00
Fix migration from pre-9.14 libraries
Some checks failed
Build / Initialization (push) Has been cancelled
Build / Code Format Validation (push) Has been cancelled
Build / Linux (Qt5) (push) Has been cancelled
Build / Linux (Qt6) (push) Has been cancelled
Build / Linux (Qt6 + 7zip) (push) Has been cancelled
Build / macOS (Qt6 Universal) (push) Has been cancelled
Build / macOS (Qt5) (push) Has been cancelled
Build / Windows x64 (Qt5) (push) Has been cancelled
Build / Windows x64 (Qt6) (push) Has been cancelled
Build / Windows ARM64 (Qt6) (push) Has been cancelled
Build / Windows x86 (Qt5) (push) Has been cancelled
Build / Docker amd64 Image (push) Has been cancelled
Build / Docker arm64 Image (push) Has been cancelled
Build / Publish Dev Builds (push) Has been cancelled
Build / Publish Release (push) Has been cancelled
Some checks failed
Build / Initialization (push) Has been cancelled
Build / Code Format Validation (push) Has been cancelled
Build / Linux (Qt5) (push) Has been cancelled
Build / Linux (Qt6) (push) Has been cancelled
Build / Linux (Qt6 + 7zip) (push) Has been cancelled
Build / macOS (Qt6 Universal) (push) Has been cancelled
Build / macOS (Qt5) (push) Has been cancelled
Build / Windows x64 (Qt5) (push) Has been cancelled
Build / Windows x64 (Qt6) (push) Has been cancelled
Build / Windows ARM64 (Qt6) (push) Has been cancelled
Build / Windows x86 (Qt5) (push) Has been cancelled
Build / Docker amd64 Image (push) Has been cancelled
Build / Docker arm64 Image (push) Has been cancelled
Build / Publish Dev Builds (push) Has been cancelled
Build / Publish Release (push) Has been cancelled
This commit is contained in:
@ -302,6 +302,87 @@ bool DataBaseManagement::createComicInfoTable(QSqlDatabase &database, QString ta
|
||||
return queryComicInfo.exec();
|
||||
}
|
||||
|
||||
bool DataBaseManagement::createComicInfoTable9_14(QSqlDatabase &database, QString tableName)
|
||||
{
|
||||
QSqlQuery queryComicInfo(database);
|
||||
queryComicInfo.prepare("CREATE TABLE " + tableName + " ("
|
||||
"id INTEGER PRIMARY KEY,"
|
||||
"title TEXT,"
|
||||
|
||||
"coverPage INTEGER DEFAULT 1,"
|
||||
"numPages INTEGER,"
|
||||
|
||||
"number TEXT," // changed to text from INTEGER (9.13)
|
||||
"isBis BOOLEAN,"
|
||||
"count INTEGER,"
|
||||
|
||||
"volume TEXT,"
|
||||
"storyArc TEXT,"
|
||||
"arcNumber TEXT," // changed to text from INTEGER (9.13)
|
||||
"arcCount INTEGER,"
|
||||
|
||||
"genere TEXT,"
|
||||
|
||||
"writer TEXT,"
|
||||
"penciller TEXT,"
|
||||
"inker TEXT,"
|
||||
"colorist TEXT,"
|
||||
"letterer TEXT,"
|
||||
"coverArtist TEXT,"
|
||||
|
||||
"date TEXT," // publication date dd/mm/yyyy --> se mostrará en 3 campos diferentes
|
||||
"publisher TEXT,"
|
||||
"format TEXT,"
|
||||
"color BOOLEAN,"
|
||||
"ageRating TEXT,"
|
||||
|
||||
"synopsis TEXT,"
|
||||
"characters TEXT,"
|
||||
"notes TEXT,"
|
||||
|
||||
"hash TEXT UNIQUE NOT NULL,"
|
||||
"edited BOOLEAN DEFAULT 0,"
|
||||
"read BOOLEAN DEFAULT 0,"
|
||||
// new 7.0 fields
|
||||
|
||||
"hasBeenOpened BOOLEAN DEFAULT 0,"
|
||||
"rating REAL DEFAULT 0," // changed to REAL from INTEGER (9.13)
|
||||
"currentPage INTEGER DEFAULT 1, "
|
||||
"bookmark1 INTEGER DEFAULT -1, "
|
||||
"bookmark2 INTEGER DEFAULT -1, "
|
||||
"bookmark3 INTEGER DEFAULT -1, "
|
||||
"brightness INTEGER DEFAULT -1, "
|
||||
"contrast INTEGER DEFAULT -1, "
|
||||
"gamma INTEGER DEFAULT -1, "
|
||||
// new 7.1 fields
|
||||
"comicVineID TEXT,"
|
||||
// new 9.5 fields
|
||||
"lastTimeOpened INTEGER,"
|
||||
"coverSizeRatio REAL,"
|
||||
"originalCoverSize STRING," // h/w
|
||||
// new 9.8 fields
|
||||
"manga BOOLEAN DEFAULT 0," // deprecated 9.13
|
||||
// new 9.13 fields
|
||||
"added INTEGER,"
|
||||
"type INTEGER DEFAULT 0," // 0 = comic, 1 = manga, 2 = manga left to right, 3 = webcomic, 4 = 4koma
|
||||
"editor TEXT,"
|
||||
"imprint TEXT,"
|
||||
"teams TEXT,"
|
||||
"locations TEXT,"
|
||||
"series TEXT,"
|
||||
"alternateSeries TEXT,"
|
||||
"alternateNumber TEXT,"
|
||||
"alternateCount INTEGER,"
|
||||
"languageISO TEXT,"
|
||||
"seriesGroup TEXT,"
|
||||
"mainCharacterOrTeam TEXT,"
|
||||
"review TEXT,"
|
||||
"tags TEXT"
|
||||
")");
|
||||
|
||||
return queryComicInfo.exec();
|
||||
}
|
||||
|
||||
bool DataBaseManagement::createV8Tables(QSqlDatabase &database)
|
||||
{
|
||||
bool success = true;
|
||||
@ -901,6 +982,9 @@ bool DataBaseManagement::updateToCurrentVersion(const QString &libraryPath)
|
||||
{
|
||||
QSqlDatabase db = loadDatabaseFromFile(libraryDatabasePath);
|
||||
if (db.isValid() && db.isOpen()) {
|
||||
|
||||
QSqlQuery pragmaFKOFF("PRAGMA foreign_keys = OFF", db);
|
||||
|
||||
if (!db.transaction()) {
|
||||
QLOG_ERROR() << "Failed to start transaction for database update";
|
||||
returnValue = false;
|
||||
@ -1066,25 +1150,26 @@ bool DataBaseManagement::updateToCurrentVersion(const QString &libraryPath)
|
||||
{
|
||||
bool pre9_14_successfulMigration = true;
|
||||
|
||||
QSqlQuery pragmaFKOFF(db);
|
||||
pragmaFKOFF.prepare("PRAGMA foreign_keys=OFF");
|
||||
pre9_14_successfulMigration = pre9_14_successfulMigration && pragmaFKOFF.exec();
|
||||
|
||||
pre9_14_successfulMigration = pre9_14_successfulMigration && createComicInfoTable(db, "comic_info_migration");
|
||||
pre9_14_successfulMigration = pre9_14_successfulMigration && createComicInfoTable9_14(db, "comic_info_migration");
|
||||
|
||||
QSqlQuery copyComicInfoToComicInfoMigration(db);
|
||||
copyComicInfoToComicInfoMigration.prepare("INSERT INTO comic_info_migration SELECT * FROM comic_info");
|
||||
|
||||
pre9_14_successfulMigration = pre9_14_successfulMigration && copyComicInfoToComicInfoMigration.exec();
|
||||
|
||||
QSqlQuery dropComicInfo(db);
|
||||
dropComicInfo.prepare("DROP TABLE comic_info");
|
||||
pre9_14_successfulMigration = pre9_14_successfulMigration && dropComicInfo.exec();
|
||||
|
||||
QLOG_ERROR() << "Migration failed1:" << dropComicInfo.lastError().text();
|
||||
|
||||
QSqlQuery renameComicInfoMigrationToComicInfo(db);
|
||||
renameComicInfoMigrationToComicInfo.prepare("ALTER TABLE comic_info_migration RENAME TO comic_info");
|
||||
pre9_14_successfulMigration = pre9_14_successfulMigration && renameComicInfoMigrationToComicInfo.exec();
|
||||
|
||||
QSqlQuery pragmaFKON1("PRAGMA foreign_keys=ON", db);
|
||||
QLOG_ERROR() << "Migration failed2:" << renameComicInfoMigrationToComicInfo.lastError().text();
|
||||
|
||||
returnValue = returnValue && pre9_14_successfulMigration;
|
||||
}
|
||||
@ -1125,7 +1210,10 @@ bool DataBaseManagement::updateToCurrentVersion(const QString &libraryPath)
|
||||
} else {
|
||||
db.rollback();
|
||||
}
|
||||
|
||||
QSqlQuery pragmaFKON("PRAGMA foreign_keys = ON", db);
|
||||
}
|
||||
|
||||
connectionName = db.connectionName();
|
||||
}
|
||||
|
||||
|
||||
@ -71,6 +71,7 @@ public:
|
||||
static QSqlDatabase loadDatabaseFromFile(QString path);
|
||||
static bool createTables(QSqlDatabase &database);
|
||||
static bool createComicInfoTable(QSqlDatabase &database, QString tableName);
|
||||
static bool createComicInfoTable9_14(QSqlDatabase &database, QString tableName);
|
||||
static bool createV8Tables(QSqlDatabase &database);
|
||||
|
||||
static void exportComicsInfo(QString source, QString dest);
|
||||
|
||||
Reference in New Issue
Block a user