- Timestamp:
- 09/25/12 23:24:05 (10 years ago)
- Branches:
- master, qt5
- Children:
- 95257a6
- Parents:
- e2c612c
- Location:
- src/sql
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sql/sqlengine.cpp
re2c612c rf1826af 82 82 83 83 bool SqlEngine::updateDbSchemaVersion000To001() { 84 emit dbError("Upgrade 0 -> 1 not implemented yet"); 85 return false; 84 return applySqlFile(":/dbschema000to001.sql"); 86 85 } 87 86 88 87 89 88 bool SqlEngine::createCurrentDbSchema() { 90 QFile file(":/dbschema001.sql"); 91 file.open(QIODevice::ReadOnly | QIODevice::Text); 92 QString allSqlStatements = file.readAll(); 93 QSqlQuery query(db); 94 foreach(QString sql, allSqlStatements.split(";")) { 95 if (sql.trimmed().isEmpty()) // do not execute empty queries like the last character from create_tables.sql 96 continue; 97 if (!query.exec(sql)) { 98 emitSqlQueryError(query); 99 return false; 100 } 101 } 102 return true; 89 return applySqlFile(":/dbschema001.sql"); 103 90 } 104 91 … … 124 111 } 125 112 return false; 113 } 114 115 116 bool SqlEngine::applySqlFile(const QString sqlFile) { 117 QFile file(sqlFile); 118 file.open(QIODevice::ReadOnly | QIODevice::Text); 119 QString allSqlStatements = file.readAll(); 120 QSqlQuery query(db); 121 foreach(QString sql, allSqlStatements.split(";")) { 122 if (sql.trimmed().isEmpty()) // do not execute empty queries like the last character from create_tables.sql 123 continue; 124 if (!query.exec(sql)) { 125 emitSqlQueryError(query); 126 return false; 127 } 128 } 129 return true; 126 130 } 127 131 -
src/sql/sqlengine.h
re2c612c rf1826af 53 53 /// otherwise updates the schema if an old one is found. true for success. 54 54 bool createOrUpdateDbSchema(); 55 /// Applies an SQL file 56 bool applySqlFile(const QString sqlFile); 55 57 56 58 // if a conferneceId != 0 is given, the confernce is updated instead of inserted.
Note: See TracChangeset
for help on using the changeset viewer.