From 7ee74dfab6b17e4e9b12011f60ba3058e31715e6 Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Sat, 9 Feb 2008 20:57:33 +0100 Subject: [PATCH] Add changedby column to source table, and fill in information found in the .changes. This will allow to identify NMUs and sponsored uploads more precisely in tools querying projectb. Also move src_uploaders after source in DB population script so the REFERNCES clause works. --- ChangeLog | 9 +++++++++ dak/process_accepted.py | 7 +++++-- setup/add_constraints.sql | 1 + setup/init_pool.sql | 13 +++++++------ 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 79a893b3..e7422486 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-02-09 Christoph Berg + + * setup/add_constraints.sql setup/init_pool.sql: Add changedby column + to source table, and move src_uploaders after source so the REFERNCES + clause works. + * dak/process_accepted.py (install): Fill the changedby column from + the information found in the .changes. This will allow to identify + NMUs and sponsored uploads more precisely in tools querying projectb. + 2008-02-06 Joerg Jaspert * daklib/utils.py (check_signature): Make variable key available, diff --git a/dak/process_accepted.py b/dak/process_accepted.py index 20aab495..3c40b97b 100755 --- a/dak/process_accepted.py +++ b/dak/process_accepted.py @@ -281,6 +281,9 @@ def install (): maintainer = dsc["maintainer"] maintainer = maintainer.replace("'", "\\'") maintainer_id = daklib.database.get_or_set_maintainer_id(maintainer) + changedby = changes["changed-by"] + changedby = changedby.replace("'", "\\'") + changedby_id = daklib.database.get_or_set_maintainer_id(changedby) fingerprint_id = daklib.database.get_or_set_fingerprint_id(dsc["fingerprint"]) install_date = time.strftime("%Y-%m-%d") filename = files[file]["pool name"] + file @@ -288,8 +291,8 @@ def install (): dsc_location_id = files[file]["location id"] if not files[file].has_key("files id") or not files[file]["files id"]: files[file]["files id"] = daklib.database.set_files_id (filename, files[file]["size"], files[file]["md5sum"], dsc_location_id) - projectB.query("INSERT INTO source (source, version, maintainer, file, install_date, sig_fpr) VALUES ('%s', '%s', %d, %d, '%s', %s)" - % (package, version, maintainer_id, files[file]["files id"], install_date, fingerprint_id)) + projectB.query("INSERT INTO source (source, version, maintainer, changedby, file, install_date, sig_fpr) VALUES ('%s', '%s', %d, %d, %d, '%s', %s)" + % (package, version, maintainer_id, changedby_id, files[file]["files id"], install_date, fingerprint_id)) for suite in changes["distribution"].keys(): suite_id = daklib.database.get_suite_id(suite) diff --git a/setup/add_constraints.sql b/setup/add_constraints.sql index 8d275502..1d2bad66 100644 --- a/setup/add_constraints.sql +++ b/setup/add_constraints.sql @@ -5,6 +5,7 @@ ALTER TABLE files ADD CONSTRAINT files_location FOREIGN KEY (location) REFERENCES location(id) MATCH FULL; ALTER TABLE source ADD CONSTRAINT source_maintainer FOREIGN KEY (maintainer) REFERENCES maintainer(id) MATCH FULL; +ALTER TABLE source ADD CONSTRAINT source_changedby FOREIGN KEY (changedby) REFERENCES maintainer(id) MATCH FULL; ALTER TABLE source ADD CONSTRAINT source_file FOREIGN KEY (file) REFERENCES files(id) MATCH FULL; ALTER TABLE source ADD CONSTRAINT source_sig_fpr FOREIGN KEY (sig_fpr) REFERENCES fingerprint(id) MATCH FULL; diff --git a/setup/init_pool.sql b/setup/init_pool.sql index 8797acd5..88777189 100644 --- a/setup/init_pool.sql +++ b/setup/init_pool.sql @@ -28,12 +28,6 @@ CREATE TABLE maintainer ( name TEXT UNIQUE NOT NULL ); -CREATE TABLE src_uploaders ( - id SERIAL PRIMARY KEY, - source INT4 NOT NULL REFERENCES source, - maintainer INT4 NOT NULL REFERENCES maintainer -); - CREATE TABLE uid ( id SERIAL PRIMARY KEY, uid TEXT UNIQUE NOT NULL, @@ -78,12 +72,19 @@ CREATE TABLE source ( source TEXT NOT NULL, version TEXT NOT NULL, maintainer INT4 NOT NULL, -- REFERENCES maintainer + changedby INT4 NOT NULL, -- REFERENCES maintainer file INT4 UNIQUE NOT NULL, -- REFERENCES files install_date TIMESTAMP NOT NULL, sig_fpr INT4 NOT NULL, -- REFERENCES fingerprint unique (source, version) ); +CREATE TABLE src_uploaders ( + id SERIAL PRIMARY KEY, + source INT4 NOT NULL REFERENCES source, + maintainer INT4 NOT NULL REFERENCES maintainer +); + CREATE TABLE dsc_files ( id SERIAL PRIMARY KEY, source INT4 NOT NULL, -- REFERENCES source, -- 2.39.2