#include <QSqlError>
#include <QSqlQuery>
+int AbstractSqlStorage::_nextConnectionId = 0;
AbstractSqlStorage::AbstractSqlStorage(QObject *parent)
: Storage(parent),
- _schemaVersion(0),
- _nextConnectionId(0)
+ _schemaVersion(0)
{
}
// disconnect the connections, so their deletion is no longer interessting for us
QHash<QThread *, Connection *>::iterator conIter;
for(conIter = _connectionPool.begin(); conIter != _connectionPool.end(); conIter++) {
+ QSqlDatabase::removeDatabase(conIter.value()->name());
disconnect(conIter.value(), 0, this, 0);
}
}
bool AbstractSqlMigrationReader::migrateTo(AbstractSqlMigrationWriter *writer) {
if(!transaction()) {
- qWarning() << "AbstractSqlMigrationReader::migrateTo(): unable to start reader stransaction!";
+ qWarning() << "AbstractSqlMigrationReader::migrateTo(): unable to start reader's transaction!";
return false;
}
if(!writer->transaction()) {
- qWarning() << "AbstractSqlMigrationReader::migrateTo(): unable to start writer stransaction!";
+ qWarning() << "AbstractSqlMigrationReader::migrateTo(): unable to start writer's transaction!";
rollback(); // close the reader transaction;
return false;
}
if(!transferMo(QuasselUser, quasselUserMo))
return false;
- SenderMO senderMo;
- if(!transferMo(Sender, senderMo))
- return false;
-
IdentityMO identityMo;
if(!transferMo(Identity, identityMo))
return false;
if(!transferMo(Buffer, bufferMo))
return false;
+ SenderMO senderMo;
+ if(!transferMo(Sender, senderMo))
+ return false;
+
BacklogMO backlogMo;
if(!transferMo(Backlog, backlogMo))
return false;
int i = 0;
QFile file;
file.open(stdout, QIODevice::WriteOnly);
+
while(readMo(mo)) {
if(!_writer->writeMo(mo)) {
abortMigration(QString("AbstractSqlMigrationReader::transferMo(): unable to transfer Migratable Object of type %1!").arg(AbstractSqlMigrator::migrationObject(moType)));
+ rollback();
+ _writer->rollback();
return false;
}
i++;
file.write("\n");
file.flush();
}
+
qDebug() << "Done.";
return true;
}