comparison src/memory/sqlite.py @ 566:9faccd827657

core: sqlite storage constraint fix
author Goffi <goffi@goffi.org>
date Mon, 07 Jan 2013 00:57:50 +0100
parents 2c4016921403
children ca13633d3b6b
comparison
equal deleted inserted replaced
565:7573897831ee 566:9faccd827657
50 "INSERT INTO message_types VALUES ('chat')", 50 "INSERT INTO message_types VALUES ('chat')",
51 "INSERT INTO message_types VALUES ('error')", 51 "INSERT INTO message_types VALUES ('error')",
52 "INSERT INTO message_types VALUES ('groupchat')", 52 "INSERT INTO message_types VALUES ('groupchat')",
53 "INSERT INTO message_types VALUES ('headline')", 53 "INSERT INTO message_types VALUES ('headline')",
54 "INSERT INTO message_types VALUES ('normal')", 54 "INSERT INTO message_types VALUES ('normal')",
55 "CREATE TABLE history (id INTEGER PRIMARY KEY ASC, profile_id INTEGER, source TEXT, dest TEXT, source_res TEXT, dest_res TEXT, timestamp DATETIME, message TEXT, type TEXT, FOREIGN KEY(profile_id) REFERENCES profiles(id), FOREIGN KEY(type) REFERENCES message_types(type))", 55 "CREATE TABLE history (id INTEGER PRIMARY KEY ASC, profile_id INTEGER, source TEXT, dest TEXT, source_res TEXT, dest_res TEXT, timestamp DATETIME, message TEXT, type TEXT, FOREIGN KEY(profile_id) REFERENCES profiles(id) ON DELETE CASCADE, FOREIGN KEY(type) REFERENCES message_types(type))",
56 "CREATE TABLE param_gen (category TEXT, name TEXT, value TEXT, PRIMARY KEY (category,name))", 56 "CREATE TABLE param_gen (category TEXT, name TEXT, value TEXT, PRIMARY KEY (category,name))",
57 "CREATE TABLE param_ind (category TEXT, name TEXT, profile_id INTEGER, value TEXT, PRIMARY KEY (category,name,profile_id), FOREIGN KEY(profile_id) REFERENCES profiles(id))", 57 "CREATE TABLE param_ind (category TEXT, name TEXT, profile_id INTEGER, value TEXT, PRIMARY KEY (category,name,profile_id), FOREIGN KEY(profile_id) REFERENCES profiles(id) ON DELETE CASCADE)",
58 "CREATE TABLE private_gen (namespace TEXT, key TEXT, value TEXT, PRIMARY KEY (namespace, key))", 58 "CREATE TABLE private_gen (namespace TEXT, key TEXT, value TEXT, PRIMARY KEY (namespace, key))",
59 "CREATE TABLE private_ind (namespace TEXT, key TEXT, profile_id INTEGER, value TEXT, PRIMARY KEY (namespace, key, profile_id), FOREIGN KEY(profile_id) REFERENCES profiles(id))", 59 "CREATE TABLE private_ind (namespace TEXT, key TEXT, profile_id INTEGER, value TEXT, PRIMARY KEY (namespace, key, profile_id), FOREIGN KEY(profile_id) REFERENCES profiles(id) ON DELETE CASCADE)",
60 "CREATE TABLE private_gen_bin (namespace TEXT, key TEXT, value BLOB, PRIMARY KEY (namespace, key))", 60 "CREATE TABLE private_gen_bin (namespace TEXT, key TEXT, value BLOB, PRIMARY KEY (namespace, key))",
61 "CREATE TABLE private_ind_bin (namespace TEXT, key TEXT, profile_id INTEGER, value BLOB, PRIMARY KEY (namespace, key, profile_id), FOREIGN KEY(profile_id) REFERENCES profiles(id))", 61 "CREATE TABLE private_ind_bin (namespace TEXT, key TEXT, profile_id INTEGER, value BLOB, PRIMARY KEY (namespace, key, profile_id), FOREIGN KEY(profile_id) REFERENCES profiles(id) ON DELETE CASCADE)",
62 ] 62 ]
63 for op in database_creation: 63 for op in database_creation:
64 d = self.dbpool.runOperation(op) 64 d = self.dbpool.runOperation(op)
65 d.addErrback(lambda x: error(_("Error while creating tables in database [QUERY: %s]") % op )) 65 d.addErrback(lambda x: error(_("Error while creating tables in database [QUERY: %s]") % op ))
66 init_defers.append(d) 66 init_defers.append(d)