changeset 36:b24cb1dd0423

Fail under certain conditions only when creating tables.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 06 Sep 2011 18:19:13 +0300
parents f4dd229b17d1
children c3c597cac4b6
files convert_spede_mn_tuksu.tcl create_spede_mn_tuksu.tcl util_convert.tcl
diffstat 3 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/convert_spede_mn_tuksu.tcl	Tue Sep 06 18:16:13 2011 +0300
+++ b/convert_spede_mn_tuksu.tcl	Tue Sep 06 18:19:13 2011 +0300
@@ -35,7 +35,7 @@
 ### Open SQLite database, drop old tables, create new
 open_db $db_output
 drop_table $db_table
-create_table_quotes_votes $db_table
+create_table_quotes_votes $db_table 1
 
 ### Convert data
 puts -nonewline "Converting database, please wait "
--- a/create_spede_mn_tuksu.tcl	Tue Sep 06 18:16:13 2011 +0300
+++ b/create_spede_mn_tuksu.tcl	Tue Sep 06 18:19:13 2011 +0300
@@ -46,7 +46,7 @@
 
 puts "Creating tables $db_str ..."
 foreach i $db_list {
-	create_table_quotes_votes $i
+	create_table_quotes_votes $i 0
 }
 
 dbh close
--- a/util_convert.tcl	Tue Sep 06 18:16:13 2011 +0300
+++ b/util_convert.tcl	Tue Sep 06 18:19:13 2011 +0300
@@ -55,7 +55,16 @@
 	create_table_or_fail "urls" "id INTEGER PRIMARY KEY AUTOINCREMENT, utime INT, url VARCHAR(2048), user VARCHAR(32), host VARCHAR(256), chan VARCHAR(32), title VARCHAR(256)"
 }
 
-proc create_table_quotes_votes { utable } {
-	create_table_or_fail "${utable}_votes" "id INTEGER PRIMARY KEY AUTOINCREMENT, user VARCHAR(32), urlid INTEGER, vote INTEGER"
-	create_table_or_fail "$utable" "id INTEGER PRIMARY KEY AUTOINCREMENT, utime INT, utext VARCHAR(2048), user VARCHAR(32), host VARCHAR(256), chan VARCHAR(32)"
+proc create_table_quotes_votes { utable ufail } {
+	
+	set sql1 "id INTEGER PRIMARY KEY AUTOINCREMENT, user VARCHAR(32), urlid INTEGER, vote INTEGER"
+	set sql2 "id INTEGER PRIMARY KEY AUTOINCREMENT, utime INT, utext VARCHAR(2048), user VARCHAR(32), host VARCHAR(256), chan VARCHAR(32)"
+
+	if {$ufail} {
+		create_table_or_fail "$utable" "$sql1"
+		create_table_or_fail "${utable}_votes" "$sql2"
+	} else {
+		create_table "$utable" "$sql1"
+		create_table "${utable}_votes" "$sql2"
+	}
 }