summaryrefslogtreecommitdiffstats
path: root/lib/Plugins/SQLite3.cpp
diff options
context:
space:
mode:
authorZdenek Prikryl <zprikryl@redhat.com>2009-08-25 17:37:24 +0200
committerZdenek Prikryl <zprikryl@redhat.com>2009-08-25 17:37:24 +0200
commitb8a2fe7059c6e1fa091fa2769d80a813b8921fb7 (patch)
tree9e0de90d8f2c81626db84f34631f1aec5cf2a9dd /lib/Plugins/SQLite3.cpp
parent7aaf0fb85fd60c04a612fe483f696a4f00f1f85e (diff)
downloadabrt-b8a2fe7059c6e1fa091fa2769d80a813b8921fb7.tar.gz
abrt-b8a2fe7059c6e1fa091fa2769d80a813b8921fb7.tar.xz
abrt-b8a2fe7059c6e1fa091fa2769d80a813b8921fb7.zip
fixed sql command for update from v1->v2
Diffstat (limited to 'lib/Plugins/SQLite3.cpp')
-rw-r--r--lib/Plugins/SQLite3.cpp32
1 files changed, 28 insertions, 4 deletions
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