diff options
author | Zdenek Prikryl <zprikryl@redhat.com> | 2009-08-25 17:37:24 +0200 |
---|---|---|
committer | Zdenek Prikryl <zprikryl@redhat.com> | 2009-08-25 17:37:24 +0200 |
commit | b8a2fe7059c6e1fa091fa2769d80a813b8921fb7 (patch) | |
tree | 9e0de90d8f2c81626db84f34631f1aec5cf2a9dd /lib | |
parent | 7aaf0fb85fd60c04a612fe483f696a4f00f1f85e (diff) | |
download | abrt-b8a2fe7059c6e1fa091fa2769d80a813b8921fb7.tar.gz abrt-b8a2fe7059c6e1fa091fa2769d80a813b8921fb7.tar.xz abrt-b8a2fe7059c6e1fa091fa2769d80a813b8921fb7.zip |
fixed sql command for update from v1->v2
Diffstat (limited to 'lib')
-rw-r--r-- | lib/MiddleWare/Database.h | 4 | ||||
-rw-r--r-- | lib/Plugins/SQLite3.cpp | 32 |
2 files changed, 30 insertions, 6 deletions
diff --git a/lib/MiddleWare/Database.h b/lib/MiddleWare/Database.h index 6566f41b..ce29f18b 100644 --- a/lib/MiddleWare/Database.h +++ b/lib/MiddleWare/Database.h @@ -30,7 +30,7 @@ /** * Table * ===== - * UUID | UID| DebugDumpPath | Count | Reported + * UUID | UID| DebugDumpPath | Count | Reported | Time | Message * * primary key (UUID, UID) */ @@ -40,8 +40,8 @@ #define DATABASE_COLUMN_DEBUG_DUMP_PATH "DebugDumpPath" #define DATABASE_COLUMN_COUNT "Count" #define DATABASE_COLUMN_REPORTED "Reported" -#define DATABASE_COLUMN_MESSAGE "Message" #define DATABASE_COLUMN_TIME "Time" +#define DATABASE_COLUMN_MESSAGE "Message" /** * A struct contains one database row. diff --git a/lib/Plugins/SQLite3.cpp b/lib/Plugins/SQLite3.cpp index 7ddd43fd..57b33172 100644 --- a/lib/Plugins/SQLite3.cpp +++ b/lib/Plugins/SQLite3.cpp @@ -33,7 +33,8 @@ #define ABRT_TABLE "abrt_v"ABRT_TABLE_VERSION_STR #define SQLITE3_MASTER_TABLE "sqlite_master" - +// afret a while, we can drom a support for update, so a table can stay in +// normal limits static const char* upate_sql_commands[][ABRT_TABLE_VERSION + 1] = { // v0 -> * { @@ -42,8 +43,10 @@ static const char* upate_sql_commands[][ABRT_TABLE_VERSION + 1] = { // v0 -> v1 "ALTER TABLE abrt ADD "DATABASE_COLUMN_MESSAGE" VARCHAR NOT NULL DEFAULT '';", // v0 -> v2 + "BEGIN TRANSACTION;" "ALTER TABLE abrt RENAME TO abrt_v2;" - "ALTER TABLE abrt_v2 ADD "DATABASE_COLUMN_MESSAGE" VARCHAR NOT NULL DEFAULT '';", + "ALTER TABLE abrt_v2 ADD "DATABASE_COLUMN_MESSAGE" VARCHAR NOT NULL DEFAULT '';" + "COMMIT;", }, //v1 -> * @@ -54,7 +57,27 @@ static const char* upate_sql_commands[][ABRT_TABLE_VERSION + 1] = { // v1 -> v1 ";", // v1 -> v2 - "ALTER TABLE abrt RENAME TO abrt_v2;", + "BEGIN TRANSACTION;" + "CREATE TABLE abrt_v2 (" + DATABASE_COLUMN_UUID" VARCHAR NOT NULL," + DATABASE_COLUMN_UID" VARCHAR NOT NULL," + DATABASE_COLUMN_DEBUG_DUMP_PATH" VARCHAR NOT NULL," + DATABASE_COLUMN_COUNT" INT NOT NULL DEFAULT 1," + DATABASE_COLUMN_REPORTED" INT NOT NULL DEFAULT 0," + DATABASE_COLUMN_TIME" VARCHAR NOT NULL DEFAULT 0," + DATABASE_COLUMN_MESSAGE" VARCHAR NOT NULL DEFAULT ''," + "PRIMARY KEY ("DATABASE_COLUMN_UUID","DATABASE_COLUMN_UID"));" + "INSERT INTO abrt_v2 " + "SELECT "DATABASE_COLUMN_UUID"," + DATABASE_COLUMN_UID"," + DATABASE_COLUMN_DEBUG_DUMP_PATH"," + DATABASE_COLUMN_COUNT"," + DATABASE_COLUMN_REPORTED"," + DATABASE_COLUMN_TIME"," + DATABASE_COLUMN_MESSAGE + " FROM abrt;" + "DROP TABLE abrt;" + "COMMIT;", }, }; @@ -206,7 +229,8 @@ bool CSQLite3::CheckTable() } return true; } - // TODO: after some time could be removed + // TODO: after some time could be removed, and if a table is that old, + // then simoply drop it and create new one else { // hack for version 0 and 1 |