-
- c.execute("CREATE TYPE package_type AS ENUM('deb','udeb','tdeb', 'dsc')")
- c.execute("ALTER TABLE binaries RENAME COLUMN type to type_text" );
- c.execute("ALTER TABLE binaries ADD COLUMN type package_type" );
- c.execute("UPDATE binaries set type=type_text::package_type" );
- c.execute("ALTER TABLE binaries DROP COLUMN type_text" );
- c.execute("CREATE INDEX binary_type_ids on binaries(type)")
-
+ # Deal with out-of-date src_uploaders entries
+ c.execute("DELETE FROM src_uploaders WHERE source NOT IN (SELECT id FROM source)")
+ c.execute("DELETE FROM src_uploaders WHERE maintainer NOT IN (SELECT id FROM maintainer)")
+ # Add constraints
+ c.execute("ALTER TABLE src_uploaders ADD CONSTRAINT src_uploaders_maintainer FOREIGN KEY (maintainer) REFERENCES maintainer(id) ON DELETE CASCADE")
+ c.execute("ALTER TABLE src_uploaders ADD CONSTRAINT src_uploaders_source FOREIGN KEY (source) REFERENCES source(id) ON DELETE CASCADE")
+ c.execute("UPDATE config SET value = '10' WHERE name = 'db_revision'")