- "create table if not exists package_app_splash_screen " \
- "(app_id text not null, " \
- "src text not null, " \
- "type text not null, " \
- "orientation text not null, " \
- "indicatordisplay text, " \
- "operation text, " \
- "color_depth text not null DEFAULT '24', " \
- "PRIMARY KEY(app_id, orientation, operation) " \
- "FOREIGN KEY(app_id) " \
- "REFERENCES package_app_info(app_id) " \
- "ON DELETE CASCADE)"
+ "CREATE TABLE IF NOT EXISTS package_app_splash_screen " \
+ "(app_id TEXT NOT NULL, " \
+ "src TEXT NOT NULL, " \
+ "type TEXT NOT NULL, " \
+ "orientation TEXT NOT NULL, " \
+ "indicatordisplay TEXT, " \
+ "operation TEXT, " \
+ "color_depth TEXT NOT NULL DEFAULT '24', " \
+ "PRIMARY KEY(app_id, orientation) " \
+ "FOREIGN KEY(app_id) " \
+ "REFERENCES package_app_info(app_id) " \
+ "ON DELETE CASCADE)"
+
+
+/* FIXME: duplicated at pkgmgrinfo_db.c */
+#define QUERY_CREATE_TABLE_PACKAGE_CERT_INDEX_INFO \
+ "CREATE TABLE IF NOT EXISTS package_cert_index_info( " \
+ " cert_info TEXT UNIQUE, " \
+ " cert_id INTEGER PRIMARY KEY, " \
+ " cert_ref_count INTEGER NOT NULL)"
+
+#define QUERY_CREATE_TABLE_PACKAGE_CERT_INFO \
+ "CREATE TABLE IF NOT EXISTS package_cert_info( " \
+ " package TEXT PRIMARY KEY, " \
+ " author_root_cert INTEGER, " \
+ " author_im_cert INTEGER, " \
+ " author_signer_cert INTEGER, " \
+ " dist_root_cert INTEGER, " \
+ " dist_im_cert INTEGER, " \
+ " dist_signer_cert INTEGER, " \
+ " dist2_root_cert INTEGER, " \
+ " dist2_im_cert INTEGER, " \
+ " dist2_signer_cert INTEGER)"
+
+#define QUERY_CREATE_TRIGGER_DELETE_CERT_INFO \
+ "CREATE TRIGGER IF NOT EXISTS delete_cert_info " \
+ "AFTER DELETE ON package_cert_info " \
+ "BEGIN" \
+ " UPDATE package_cert_index_info SET" \
+ " cert_ref_count = cert_ref_count - 1" \
+ " WHERE cert_id = OLD.author_root_cert" \
+ " OR cert_id = OLD.author_im_cert" \
+ " OR cert_id = OLD.author_signer_cert" \
+ " OR cert_id = OLD.dist_root_cert" \
+ " OR cert_id = OLD.dist_im_cert" \
+ " OR cert_id = OLD.dist_signer_cert" \
+ " OR cert_id = OLD.dist2_root_cert" \
+ " OR cert_id = OLD.dist2_im_cert" \
+ " OR cert_id = OLD.dist2_signer_cert;" \
+ "END;"
+
+#define QUERY_CREATE_TRIGGER_UPDATE_CERT_INDEX_INFO \
+ "CREATE TRIGGER IF NOT EXISTS update_cert_index_info " \
+ "AFTER UPDATE ON package_cert_index_info " \
+ "WHEN ((SELECT cert_ref_count FROM package_cert_index_info " \
+ " WHERE cert_id = OLD.cert_id) = 0) "\
+ "BEGIN" \
+ " DELETE FROM package_cert_index_info WHERE cert_id = OLD.cert_id;" \
+ "END;"
+
+#define QUERY_CREATE_TRIGGER_UPDATE_CERT_INFO_FORMAT \
+ "CREATE TRIGGER IF NOT EXISTS update_%s_info " \
+ "AFTER UPDATE ON package_cert_info " \
+ "WHEN (OLD.%s IS NOT NULL) " \
+ "BEGIN" \
+ " UPDATE package_cert_index_info SET" \
+ " cert_ref_count = cert_ref_count - 1" \
+ " WHERE cert_id = OLD.%s;" \
+ "END;"