Merge commit 'f90f6b856d' into mead

Conflicts:
	cli/koji
	docs/schema.sql
	hub/kojihub.py
	koji.spec
	www/kojiweb/index.py
	www/kojiweb/taskinfo.chtml
This commit is contained in:
Mike McLean 2010-04-08 17:12:49 -04:00
commit c742272ac6
22 changed files with 1913 additions and 899 deletions

View file

@ -0,0 +1,204 @@
-- upgrade script to migrate the Koji database schema
-- from version 1.3 to 1.4
BEGIN;
-- First the simple stuff. A pair of new host fields.
ALTER TABLE host ADD COLUMN description TEXT;
ALTER TABLE host ADD COLUMN comment TEXT;
-- ...and a new field for tasks
ALTER TABLE task ADD COLUMN start_time TIMESTAMP;
-- The rest updates all the versioned tables to track who did what
-- One issue with this is that we need to provide creator/revoker data
-- for existing rows. Our approach is to create a disabled user to use
-- for this named 'nobody'. The temporary function is merely a convenient
-- way to reference the user we create.
INSERT INTO users (name, status, usertype) VALUES ('nobody', 1, 0);
CREATE FUNCTION pg_temp.user() returns INTEGER as $$ select id from users where name='nobody' $$ language SQL;
-- If you would like to use an existing user instead, then:
-- 1. comment out the users insert
-- 2. edit the temporary function to look for the alternate user name
SELECT 'Updating table user_perms';
ALTER TABLE user_perms ADD COLUMN creator_id INTEGER REFERENCES users(id);
ALTER TABLE user_perms ADD COLUMN revoker_id INTEGER REFERENCES users(id);
UPDATE user_perms SET creator_id=pg_temp.user() WHERE creator_id IS NULL;
UPDATE user_perms SET revoker_id=pg_temp.user() WHERE revoker_id IS NULL AND revoke_event IS NOT NULL;
ALTER TABLE user_perms ALTER COLUMN creator_id SET NOT NULL;
ALTER TABLE user_perms DROP CONSTRAINT active_revoke_sane;
ALTER TABLE user_perms ADD CONSTRAINT active_revoke_sane CHECK (
(active IS NULL AND revoke_event IS NOT NULL AND revoker_id IS NOT NULL)
OR (active IS NOT NULL AND revoke_event IS NULL AND revoker_id IS NULL));
SELECT 'Updating table user_groups';
ALTER TABLE user_groups ADD COLUMN creator_id INTEGER REFERENCES users(id);
ALTER TABLE user_groups ADD COLUMN revoker_id INTEGER REFERENCES users(id);
UPDATE user_groups SET creator_id=pg_temp.user() WHERE creator_id IS NULL;
UPDATE user_groups SET revoker_id=pg_temp.user() WHERE revoker_id IS NULL AND revoke_event IS NOT NULL;
ALTER TABLE user_groups ALTER COLUMN creator_id SET NOT NULL;
ALTER TABLE user_groups DROP CONSTRAINT active_revoke_sane;
ALTER TABLE user_groups ADD CONSTRAINT active_revoke_sane CHECK (
(active IS NULL AND revoke_event IS NOT NULL AND revoker_id IS NOT NULL)
OR (active IS NOT NULL AND revoke_event IS NULL AND revoker_id IS NULL));
SELECT 'Updating table tag_inheritance';
ALTER TABLE tag_inheritance ADD COLUMN creator_id INTEGER REFERENCES users(id);
ALTER TABLE tag_inheritance ADD COLUMN revoker_id INTEGER REFERENCES users(id);
UPDATE tag_inheritance SET creator_id=pg_temp.user() WHERE creator_id IS NULL;
UPDATE tag_inheritance SET revoker_id=pg_temp.user() WHERE revoker_id IS NULL AND revoke_event IS NOT NULL;
ALTER TABLE tag_inheritance ALTER COLUMN creator_id SET NOT NULL;
ALTER TABLE tag_inheritance DROP CONSTRAINT active_revoke_sane;
ALTER TABLE tag_inheritance ADD CONSTRAINT active_revoke_sane CHECK (
(active IS NULL AND revoke_event IS NOT NULL AND revoker_id IS NOT NULL)
OR (active IS NOT NULL AND revoke_event IS NULL AND revoker_id IS NULL));
SELECT 'Updating table tag_config';
ALTER TABLE tag_config ADD COLUMN creator_id INTEGER REFERENCES users(id);
ALTER TABLE tag_config ADD COLUMN revoker_id INTEGER REFERENCES users(id);
UPDATE tag_config SET creator_id=pg_temp.user() WHERE creator_id IS NULL;
UPDATE tag_config SET revoker_id=pg_temp.user() WHERE revoker_id IS NULL AND revoke_event IS NOT NULL;
ALTER TABLE tag_config ALTER COLUMN creator_id SET NOT NULL;
ALTER TABLE tag_config DROP CONSTRAINT active_revoke_sane;
ALTER TABLE tag_config ADD CONSTRAINT active_revoke_sane CHECK (
(active IS NULL AND revoke_event IS NOT NULL AND revoker_id IS NOT NULL)
OR (active IS NOT NULL AND revoke_event IS NULL AND revoker_id IS NULL));
SELECT 'Updating table build_target_config';
ALTER TABLE build_target_config ADD COLUMN creator_id INTEGER REFERENCES users(id);
ALTER TABLE build_target_config ADD COLUMN revoker_id INTEGER REFERENCES users(id);
UPDATE build_target_config SET creator_id=pg_temp.user() WHERE creator_id IS NULL;
UPDATE build_target_config SET revoker_id=pg_temp.user() WHERE revoker_id IS NULL AND revoke_event IS NOT NULL;
ALTER TABLE build_target_config ALTER COLUMN creator_id SET NOT NULL;
ALTER TABLE build_target_config DROP CONSTRAINT active_revoke_sane;
ALTER TABLE build_target_config ADD CONSTRAINT active_revoke_sane CHECK (
(active IS NULL AND revoke_event IS NOT NULL AND revoker_id IS NOT NULL)
OR (active IS NOT NULL AND revoke_event IS NULL AND revoker_id IS NULL));
SELECT 'Updating table external_repo_config';
ALTER TABLE external_repo_config ADD COLUMN creator_id INTEGER REFERENCES users(id);
ALTER TABLE external_repo_config ADD COLUMN revoker_id INTEGER REFERENCES users(id);
UPDATE external_repo_config SET creator_id=pg_temp.user() WHERE creator_id IS NULL;
UPDATE external_repo_config SET revoker_id=pg_temp.user() WHERE revoker_id IS NULL AND revoke_event IS NOT NULL;
ALTER TABLE external_repo_config ALTER COLUMN creator_id SET NOT NULL;
ALTER TABLE external_repo_config DROP CONSTRAINT active_revoke_sane;
ALTER TABLE external_repo_config ADD CONSTRAINT active_revoke_sane CHECK (
(active IS NULL AND revoke_event IS NOT NULL AND revoker_id IS NOT NULL)
OR (active IS NOT NULL AND revoke_event IS NULL AND revoker_id IS NULL));
SELECT 'Updating table tag_external_repos';
ALTER TABLE tag_external_repos ADD COLUMN creator_id INTEGER REFERENCES users(id);
ALTER TABLE tag_external_repos ADD COLUMN revoker_id INTEGER REFERENCES users(id);
UPDATE tag_external_repos SET creator_id=pg_temp.user() WHERE creator_id IS NULL;
UPDATE tag_external_repos SET revoker_id=pg_temp.user() WHERE revoker_id IS NULL AND revoke_event IS NOT NULL;
ALTER TABLE tag_external_repos ALTER COLUMN creator_id SET NOT NULL;
ALTER TABLE tag_external_repos DROP CONSTRAINT active_revoke_sane;
ALTER TABLE tag_external_repos ADD CONSTRAINT active_revoke_sane CHECK (
(active IS NULL AND revoke_event IS NOT NULL AND revoker_id IS NOT NULL)
OR (active IS NOT NULL AND revoke_event IS NULL AND revoker_id IS NULL));
SELECT 'Updating table tag_listing';
ALTER TABLE tag_listing ADD COLUMN creator_id INTEGER REFERENCES users(id);
ALTER TABLE tag_listing ADD COLUMN revoker_id INTEGER REFERENCES users(id);
UPDATE tag_listing SET creator_id=pg_temp.user() WHERE creator_id IS NULL;
UPDATE tag_listing SET revoker_id=pg_temp.user() WHERE revoker_id IS NULL AND revoke_event IS NOT NULL;
ALTER TABLE tag_listing ALTER COLUMN creator_id SET NOT NULL;
ALTER TABLE tag_listing DROP CONSTRAINT active_revoke_sane;
ALTER TABLE tag_listing ADD CONSTRAINT active_revoke_sane CHECK (
(active IS NULL AND revoke_event IS NOT NULL AND revoker_id IS NOT NULL)
OR (active IS NOT NULL AND revoke_event IS NULL AND revoker_id IS NULL));
SELECT 'Updating table tag_packages';
ALTER TABLE tag_packages ADD COLUMN creator_id INTEGER REFERENCES users(id);
ALTER TABLE tag_packages ADD COLUMN revoker_id INTEGER REFERENCES users(id);
UPDATE tag_packages SET creator_id=pg_temp.user() WHERE creator_id IS NULL;
UPDATE tag_packages SET revoker_id=pg_temp.user() WHERE revoker_id IS NULL AND revoke_event IS NOT NULL;
ALTER TABLE tag_packages ALTER COLUMN creator_id SET NOT NULL;
ALTER TABLE tag_packages DROP CONSTRAINT active_revoke_sane;
ALTER TABLE tag_packages ADD CONSTRAINT active_revoke_sane CHECK (
(active IS NULL AND revoke_event IS NOT NULL AND revoker_id IS NOT NULL)
OR (active IS NOT NULL AND revoke_event IS NULL AND revoker_id IS NULL));
SELECT 'Updating table group_config';
ALTER TABLE group_config ADD COLUMN creator_id INTEGER REFERENCES users(id);
ALTER TABLE group_config ADD COLUMN revoker_id INTEGER REFERENCES users(id);
UPDATE group_config SET creator_id=pg_temp.user() WHERE creator_id IS NULL;
UPDATE group_config SET revoker_id=pg_temp.user() WHERE revoker_id IS NULL AND revoke_event IS NOT NULL;
ALTER TABLE group_config ALTER COLUMN creator_id SET NOT NULL;
ALTER TABLE group_config DROP CONSTRAINT active_revoke_sane;
ALTER TABLE group_config ADD CONSTRAINT active_revoke_sane CHECK (
(active IS NULL AND revoke_event IS NOT NULL AND revoker_id IS NOT NULL)
OR (active IS NOT NULL AND revoke_event IS NULL AND revoker_id IS NULL));
SELECT 'Updating table group_req_listing';
ALTER TABLE group_req_listing ADD COLUMN creator_id INTEGER REFERENCES users(id);
ALTER TABLE group_req_listing ADD COLUMN revoker_id INTEGER REFERENCES users(id);
UPDATE group_req_listing SET creator_id=pg_temp.user() WHERE creator_id IS NULL;
UPDATE group_req_listing SET revoker_id=pg_temp.user() WHERE revoker_id IS NULL AND revoke_event IS NOT NULL;
ALTER TABLE group_req_listing ALTER COLUMN creator_id SET NOT NULL;
ALTER TABLE group_req_listing DROP CONSTRAINT active_revoke_sane;
ALTER TABLE group_req_listing ADD CONSTRAINT active_revoke_sane CHECK (
(active IS NULL AND revoke_event IS NOT NULL AND revoker_id IS NOT NULL)
OR (active IS NOT NULL AND revoke_event IS NULL AND revoker_id IS NULL));
SELECT 'Updating table group_package_listing';
ALTER TABLE group_package_listing ADD COLUMN creator_id INTEGER REFERENCES users(id);
ALTER TABLE group_package_listing ADD COLUMN revoker_id INTEGER REFERENCES users(id);
UPDATE group_package_listing SET creator_id=pg_temp.user() WHERE creator_id IS NULL;
UPDATE group_package_listing SET revoker_id=pg_temp.user() WHERE revoker_id IS NULL AND revoke_event IS NOT NULL;
ALTER TABLE group_package_listing ALTER COLUMN creator_id SET NOT NULL;
ALTER TABLE group_package_listing DROP CONSTRAINT active_revoke_sane;
ALTER TABLE group_package_listing ADD CONSTRAINT active_revoke_sane CHECK (
(active IS NULL AND revoke_event IS NOT NULL AND revoker_id IS NOT NULL)
OR (active IS NOT NULL AND revoke_event IS NULL AND revoker_id IS NULL));
COMMIT;

View file

@ -101,6 +101,7 @@ INSERT INTO permissions (name) VALUES ('build');
INSERT INTO permissions (name) VALUES ('repo');
INSERT INTO permissions (name) VALUES ('livecd');
INSERT INTO permissions (name) VALUES ('maven-import');
INSERT INTO permissions (name) VALUES ('appliance');
CREATE TABLE user_perms (
user_id INTEGER NOT NULL REFERENCES users(id),
@ -108,10 +109,12 @@ CREATE TABLE user_perms (
-- versioned - see VERSIONING
create_event INTEGER NOT NULL REFERENCES events(id) DEFAULT get_event(),
revoke_event INTEGER REFERENCES events(id),
creator_id INTEGER NOT NULL REFERENCES users(id),
revoker_id INTEGER REFERENCES users(id),
active BOOLEAN DEFAULT 'true' CHECK (active),
CONSTRAINT active_revoke_sane CHECK (
(active IS NULL AND revoke_event IS NOT NULL )
OR (active IS NOT NULL AND revoke_event IS NULL )),
(active IS NULL AND revoke_event IS NOT NULL AND revoker_id IS NOT NULL)
OR (active IS NOT NULL AND revoke_event IS NULL AND revoker_id IS NULL)),
PRIMARY KEY (create_event, user_id, perm_id),
UNIQUE (user_id,perm_id,active)
) WITHOUT OIDS;
@ -123,10 +126,12 @@ CREATE TABLE user_groups (
-- versioned - see VERSIONING
create_event INTEGER NOT NULL REFERENCES events(id) DEFAULT get_event(),
revoke_event INTEGER REFERENCES events(id),
creator_id INTEGER NOT NULL REFERENCES users(id),
revoker_id INTEGER REFERENCES users(id),
active BOOLEAN DEFAULT 'true' CHECK (active),
CONSTRAINT active_revoke_sane CHECK (
(active IS NULL AND revoke_event IS NOT NULL )
OR (active IS NOT NULL AND revoke_event IS NULL )),
(active IS NULL AND revoke_event IS NOT NULL AND revoker_id IS NOT NULL)
OR (active IS NOT NULL AND revoke_event IS NULL AND revoker_id IS NULL)),
PRIMARY KEY (create_event, user_id, group_id),
UNIQUE (user_id,group_id,active)
) WITHOUT OIDS;
@ -173,6 +178,7 @@ INSERT INTO channels (name) VALUES ('default');
INSERT INTO channels (name) VALUES ('createrepo');
INSERT INTO channels (name) VALUES ('maven');
INSERT INTO channels (name) VALUES ('livecd');
INSERT INTO channels (name) VALUES ('appliance');
-- Here we track the build machines
-- each host has an entry in the users table also
@ -184,6 +190,8 @@ CREATE TABLE host (
arches TEXT,
task_load FLOAT CHECK (NOT task_load < 0) NOT NULL DEFAULT 0.0,
capacity FLOAT CHECK (capacity > 1) NOT NULL DEFAULT 2.0,
description TEXT,
comment TEXT,
ready BOOLEAN NOT NULL DEFAULT 'false',
enabled BOOLEAN NOT NULL DEFAULT 'true'
) WITHOUT OIDS;
@ -213,6 +221,7 @@ CREATE TABLE task (
id SERIAL NOT NULL PRIMARY KEY,
state INTEGER,
create_time TIMESTAMP NOT NULL DEFAULT NOW(),
start_time TIMESTAMP,
completion_time TIMESTAMP,
channel_id INTEGER NOT NULL REFERENCES channels(id),
host_id INTEGER REFERENCES host (id),
@ -313,10 +322,12 @@ CREATE TABLE tag_inheritance (
-- versioned - see desc above
create_event INTEGER NOT NULL REFERENCES events(id) DEFAULT get_event(),
revoke_event INTEGER REFERENCES events(id),
creator_id INTEGER NOT NULL REFERENCES users(id),
revoker_id INTEGER REFERENCES users(id),
active BOOLEAN DEFAULT 'true' CHECK (active),
CONSTRAINT active_revoke_sane CHECK (
(active IS NULL AND revoke_event IS NOT NULL )
OR (active IS NOT NULL AND revoke_event IS NULL )),
(active IS NULL AND revoke_event IS NOT NULL AND revoker_id IS NOT NULL)
OR (active IS NOT NULL AND revoke_event IS NULL AND revoker_id IS NULL)),
PRIMARY KEY (create_event, tag_id, priority),
UNIQUE (tag_id,priority,active),
UNIQUE (tag_id,parent_id,active)
@ -337,10 +348,12 @@ CREATE TABLE tag_config (
-- versioned - see desc above
create_event INTEGER NOT NULL REFERENCES events(id) DEFAULT get_event(),
revoke_event INTEGER REFERENCES events(id),
creator_id INTEGER NOT NULL REFERENCES users(id),
revoker_id INTEGER REFERENCES users(id),
active BOOLEAN DEFAULT 'true' CHECK (active),
CONSTRAINT active_revoke_sane CHECK (
(active IS NULL AND revoke_event IS NOT NULL )
OR (active IS NOT NULL AND revoke_event IS NULL )),
(active IS NULL AND revoke_event IS NOT NULL AND revoker_id IS NOT NULL)
OR (active IS NOT NULL AND revoke_event IS NULL AND revoker_id IS NULL)),
PRIMARY KEY (create_event, tag_id),
UNIQUE (tag_id,active)
) WITHOUT OIDS;
@ -361,10 +374,12 @@ CREATE TABLE build_target_config (
-- versioned - see desc above
create_event INTEGER NOT NULL REFERENCES events(id) DEFAULT get_event(),
revoke_event INTEGER REFERENCES events(id),
creator_id INTEGER NOT NULL REFERENCES users(id),
revoker_id INTEGER REFERENCES users(id),
active BOOLEAN DEFAULT 'true' CHECK (active),
CONSTRAINT active_revoke_sane CHECK (
(active IS NULL AND revoke_event IS NOT NULL )
OR (active IS NOT NULL AND revoke_event IS NULL )),
(active IS NULL AND revoke_event IS NOT NULL AND revoker_id IS NOT NULL)
OR (active IS NOT NULL AND revoke_event IS NULL AND revoker_id IS NULL)),
PRIMARY KEY (create_event, build_target_id),
UNIQUE (build_target_id,active)
) WITHOUT OIDS;
@ -392,10 +407,12 @@ create table external_repo_config (
-- versioned - see earlier description of versioning
create_event INTEGER NOT NULL REFERENCES events(id) DEFAULT get_event(),
revoke_event INTEGER REFERENCES events(id),
creator_id INTEGER NOT NULL REFERENCES users(id),
revoker_id INTEGER REFERENCES users(id),
active BOOLEAN DEFAULT 'true' CHECK (active),
CONSTRAINT active_revoke_sane CHECK (
(active IS NULL AND revoke_event IS NOT NULL )
OR (active IS NOT NULL AND revoke_event IS NULL )),
(active IS NULL AND revoke_event IS NOT NULL AND revoker_id IS NOT NULL)
OR (active IS NOT NULL AND revoke_event IS NULL AND revoker_id IS NULL)),
PRIMARY KEY (create_event, external_repo_id),
UNIQUE (external_repo_id, active)
) WITHOUT OIDS;
@ -407,10 +424,12 @@ create table tag_external_repos (
-- versioned - see earlier description of versioning
create_event INTEGER NOT NULL REFERENCES events(id) DEFAULT get_event(),
revoke_event INTEGER REFERENCES events(id),
creator_id INTEGER NOT NULL REFERENCES users(id),
revoker_id INTEGER REFERENCES users(id),
active BOOLEAN DEFAULT 'true' CHECK (active),
CONSTRAINT active_revoke_sane CHECK (
(active IS NULL AND revoke_event IS NOT NULL )
OR (active IS NOT NULL AND revoke_event IS NULL )),
(active IS NULL AND revoke_event IS NOT NULL AND revoker_id IS NOT NULL)
OR (active IS NOT NULL AND revoke_event IS NULL AND revoker_id IS NULL)),
PRIMARY KEY (create_event, tag_id, priority),
UNIQUE (tag_id, priority, active),
UNIQUE (tag_id, external_repo_id, active)
@ -448,10 +467,12 @@ CREATE TABLE tag_listing (
-- versioned - see earlier description of versioning
create_event INTEGER NOT NULL REFERENCES events(id) DEFAULT get_event(),
revoke_event INTEGER REFERENCES events(id),
creator_id INTEGER NOT NULL REFERENCES users(id),
revoker_id INTEGER REFERENCES users(id),
active BOOLEAN DEFAULT 'true' CHECK (active),
CONSTRAINT active_revoke_sane CHECK (
(active IS NULL AND revoke_event IS NOT NULL )
OR (active IS NOT NULL AND revoke_event IS NULL )),
(active IS NULL AND revoke_event IS NOT NULL AND revoker_id IS NOT NULL)
OR (active IS NOT NULL AND revoke_event IS NULL AND revoker_id IS NULL)),
PRIMARY KEY (create_event, build_id, tag_id),
UNIQUE (build_id,tag_id,active)
) WITHOUT OIDS;
@ -473,10 +494,12 @@ CREATE TABLE tag_packages (
-- versioned - see earlier description of versioning
create_event INTEGER NOT NULL REFERENCES events(id) DEFAULT get_event(),
revoke_event INTEGER REFERENCES events(id),
creator_id INTEGER NOT NULL REFERENCES users(id),
revoker_id INTEGER REFERENCES users(id),
active BOOLEAN DEFAULT 'true' CHECK (active),
CONSTRAINT active_revoke_sane CHECK (
(active IS NULL AND revoke_event IS NOT NULL )
OR (active IS NOT NULL AND revoke_event IS NULL )),
(active IS NULL AND revoke_event IS NOT NULL AND revoker_id IS NOT NULL)
OR (active IS NOT NULL AND revoke_event IS NULL AND revoker_id IS NULL)),
PRIMARY KEY (create_event, package_id, tag_id),
UNIQUE (package_id,tag_id,active)
) WITHOUT OIDS;
@ -504,10 +527,12 @@ CREATE TABLE group_config (
-- versioned - see earlier description of versioning
create_event INTEGER NOT NULL REFERENCES events(id) DEFAULT get_event(),
revoke_event INTEGER REFERENCES events(id),
creator_id INTEGER NOT NULL REFERENCES users(id),
revoker_id INTEGER REFERENCES users(id),
active BOOLEAN DEFAULT 'true' CHECK (active),
CONSTRAINT active_revoke_sane CHECK (
(active IS NULL AND revoke_event IS NOT NULL )
OR (active IS NOT NULL AND revoke_event IS NULL )),
(active IS NULL AND revoke_event IS NOT NULL AND revoker_id IS NOT NULL)
OR (active IS NOT NULL AND revoke_event IS NULL AND revoker_id IS NULL)),
PRIMARY KEY (create_event, group_id, tag_id),
UNIQUE (group_id,tag_id,active)
) WITHOUT OIDS;
@ -522,10 +547,12 @@ CREATE TABLE group_req_listing (
-- versioned - see earlier description of versioning
create_event INTEGER NOT NULL REFERENCES events(id) DEFAULT get_event(),
revoke_event INTEGER REFERENCES events(id),
creator_id INTEGER NOT NULL REFERENCES users(id),
revoker_id INTEGER REFERENCES users(id),
active BOOLEAN DEFAULT 'true' CHECK (active),
CONSTRAINT active_revoke_sane CHECK (
(active IS NULL AND revoke_event IS NOT NULL )
OR (active IS NOT NULL AND revoke_event IS NULL )),
(active IS NULL AND revoke_event IS NOT NULL AND revoker_id IS NOT NULL)
OR (active IS NOT NULL AND revoke_event IS NULL AND revoker_id IS NULL)),
PRIMARY KEY (create_event, group_id, tag_id, req_id),
UNIQUE (group_id,tag_id,req_id,active)
) WITHOUT OIDS;
@ -545,10 +572,12 @@ CREATE TABLE group_package_listing (
-- versioned - see earlier description of versioning
create_event INTEGER NOT NULL REFERENCES events(id) DEFAULT get_event(),
revoke_event INTEGER REFERENCES events(id),
creator_id INTEGER NOT NULL REFERENCES users(id),
revoker_id INTEGER REFERENCES users(id),
active BOOLEAN DEFAULT 'true' CHECK (active),
CONSTRAINT active_revoke_sane CHECK (
(active IS NULL AND revoke_event IS NOT NULL )
OR (active IS NOT NULL AND revoke_event IS NULL )),
(active IS NULL AND revoke_event IS NOT NULL AND revoker_id IS NOT NULL)
OR (active IS NOT NULL AND revoke_event IS NULL AND revoker_id IS NULL)),
PRIMARY KEY (create_event, group_id, tag_id, package),
UNIQUE (group_id,tag_id,package,active)
) WITHOUT OIDS;