mirror of
https://github.com/YACReader/yacreader
synced 2026-02-15 11:33:00 -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:
@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
Version counting is based on semantic versioning (Major.Feature.Patch)
|
Version counting is based on semantic versioning (Major.Feature.Patch)
|
||||||
|
|
||||||
|
## 9.16.4
|
||||||
|
|
||||||
|
### YACReaderLibrary
|
||||||
|
* Fix migration from pre-9.14 libraries.
|
||||||
|
|
||||||
## 9.16.3
|
## 9.16.3
|
||||||
|
|
||||||
### YACReader
|
### YACReader
|
||||||
|
|||||||
@ -302,6 +302,87 @@ bool DataBaseManagement::createComicInfoTable(QSqlDatabase &database, QString ta
|
|||||||
return queryComicInfo.exec();
|
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 DataBaseManagement::createV8Tables(QSqlDatabase &database)
|
||||||
{
|
{
|
||||||
bool success = true;
|
bool success = true;
|
||||||
@ -901,6 +982,9 @@ bool DataBaseManagement::updateToCurrentVersion(const QString &libraryPath)
|
|||||||
{
|
{
|
||||||
QSqlDatabase db = loadDatabaseFromFile(libraryDatabasePath);
|
QSqlDatabase db = loadDatabaseFromFile(libraryDatabasePath);
|
||||||
if (db.isValid() && db.isOpen()) {
|
if (db.isValid() && db.isOpen()) {
|
||||||
|
|
||||||
|
QSqlQuery pragmaFKOFF("PRAGMA foreign_keys = OFF", db);
|
||||||
|
|
||||||
if (!db.transaction()) {
|
if (!db.transaction()) {
|
||||||
QLOG_ERROR() << "Failed to start transaction for database update";
|
QLOG_ERROR() << "Failed to start transaction for database update";
|
||||||
returnValue = false;
|
returnValue = false;
|
||||||
@ -1066,25 +1150,26 @@ bool DataBaseManagement::updateToCurrentVersion(const QString &libraryPath)
|
|||||||
{
|
{
|
||||||
bool pre9_14_successfulMigration = true;
|
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 && 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);
|
QSqlQuery copyComicInfoToComicInfoMigration(db);
|
||||||
copyComicInfoToComicInfoMigration.prepare("INSERT INTO comic_info_migration SELECT * FROM comic_info");
|
copyComicInfoToComicInfoMigration.prepare("INSERT INTO comic_info_migration SELECT * FROM comic_info");
|
||||||
|
|
||||||
pre9_14_successfulMigration = pre9_14_successfulMigration && copyComicInfoToComicInfoMigration.exec();
|
pre9_14_successfulMigration = pre9_14_successfulMigration && copyComicInfoToComicInfoMigration.exec();
|
||||||
|
|
||||||
QSqlQuery dropComicInfo(db);
|
QSqlQuery dropComicInfo(db);
|
||||||
dropComicInfo.prepare("DROP TABLE comic_info");
|
dropComicInfo.prepare("DROP TABLE comic_info");
|
||||||
pre9_14_successfulMigration = pre9_14_successfulMigration && dropComicInfo.exec();
|
pre9_14_successfulMigration = pre9_14_successfulMigration && dropComicInfo.exec();
|
||||||
|
|
||||||
|
QLOG_ERROR() << "Migration failed1:" << dropComicInfo.lastError().text();
|
||||||
|
|
||||||
QSqlQuery renameComicInfoMigrationToComicInfo(db);
|
QSqlQuery renameComicInfoMigrationToComicInfo(db);
|
||||||
renameComicInfoMigrationToComicInfo.prepare("ALTER TABLE comic_info_migration RENAME TO comic_info");
|
renameComicInfoMigrationToComicInfo.prepare("ALTER TABLE comic_info_migration RENAME TO comic_info");
|
||||||
pre9_14_successfulMigration = pre9_14_successfulMigration && renameComicInfoMigrationToComicInfo.exec();
|
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;
|
returnValue = returnValue && pre9_14_successfulMigration;
|
||||||
}
|
}
|
||||||
@ -1125,7 +1210,10 @@ bool DataBaseManagement::updateToCurrentVersion(const QString &libraryPath)
|
|||||||
} else {
|
} else {
|
||||||
db.rollback();
|
db.rollback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSqlQuery pragmaFKON("PRAGMA foreign_keys = ON", db);
|
||||||
}
|
}
|
||||||
|
|
||||||
connectionName = db.connectionName();
|
connectionName = db.connectionName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -71,6 +71,7 @@ public:
|
|||||||
static QSqlDatabase loadDatabaseFromFile(QString path);
|
static QSqlDatabase loadDatabaseFromFile(QString path);
|
||||||
static bool createTables(QSqlDatabase &database);
|
static bool createTables(QSqlDatabase &database);
|
||||||
static bool createComicInfoTable(QSqlDatabase &database, QString tableName);
|
static bool createComicInfoTable(QSqlDatabase &database, QString tableName);
|
||||||
|
static bool createComicInfoTable9_14(QSqlDatabase &database, QString tableName);
|
||||||
static bool createV8Tables(QSqlDatabase &database);
|
static bool createV8Tables(QSqlDatabase &database);
|
||||||
|
|
||||||
static void exportComicsInfo(QString source, QString dest);
|
static void exportComicsInfo(QString source, QString dest);
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
class QLibrary;
|
class QLibrary;
|
||||||
|
|
||||||
#define VERSION "9.16.3"
|
#define VERSION "9.16.4"
|
||||||
|
|
||||||
// Used to check if the database needs to be updated, the version is stored in the database.
|
// Used to check if the database needs to be updated, the version is stored in the database.
|
||||||
// This value is only incremented when the database structure changes.
|
// This value is only incremented when the database structure changes.
|
||||||
|
|||||||
Reference in New Issue
Block a user