ykarel / centos / cbs-tools

Forked from centos/cbs-tools 4 years ago
Clone

Blame scripts/migration/schema-upgrade-1.17-1.18.sql

Thomas Oulevey 98f397
-- upgrade script to migrate the Koji database schema
Thomas Oulevey 98f397
-- from version 1.17 to 1.18
Thomas Oulevey 98f397
Thomas Oulevey 98f397
Thomas Oulevey 98f397
BEGIN;
Thomas Oulevey 98f397
Thomas Oulevey 98f397
-- new table for notifications' optouts
Thomas Oulevey 98f397
CREATE TABLE build_notifications_block (
Thomas Oulevey 98f397
    id SERIAL NOT NULL PRIMARY KEY,
Thomas Oulevey 98f397
    user_id INTEGER NOT NULL REFERENCES users (id),
Thomas Oulevey 98f397
    package_id INTEGER REFERENCES package (id),
Thomas Oulevey 98f397
    tag_id INTEGER REFERENCES tag (id)
Thomas Oulevey 98f397
) WITHOUT OIDS;
Thomas Oulevey 98f397
Thomas Oulevey 98f397
-- add tgz to list of tar's extensions
Thomas Oulevey 98f397
UPDATE archivetypes SET extensions = 'tar tar.gz tar.bz2 tar.xz tgz' WHERE name = 'tar';
Thomas Oulevey 98f397
INSERT INTO archivetypes (name, description, extensions) VALUES ('vhdx', 'Hyper-V Virtual Hard Disk v2 image', 'vhdx');
Thomas Oulevey 98f397
Thomas Oulevey 98f397
-- add compressed raw-gzip and compressed qcow2 images
Thomas Oulevey 98f397
insert into archivetypes (name, description, extensions) values ('raw-gz', 'GZIP compressed raw disk image', 'raw.gz');
Thomas Oulevey 98f397
insert into archivetypes (name, description, extensions) values ('qcow2-compressed', 'Compressed QCOW2 image', 'qcow2.gz qcow2.xz');
Thomas Oulevey 98f397
Thomas Oulevey 98f397
-- add better index for sessions
Thomas Oulevey 98f397
CREATE INDEX sessions_expired ON sessions(expired);
Thomas Oulevey 98f397
Thomas Oulevey 98f397
-- table for content generator build reservations
Thomas Oulevey 98f397
CREATE TABLE build_reservations (
Thomas Oulevey 98f397
	build_id INTEGER NOT NULL REFERENCES build(id),
Thomas Oulevey 98f397
	token VARCHAR(64),
Thomas Oulevey 98f397
        created TIMESTAMP NOT NULL,
Thomas Oulevey 98f397
	PRIMARY KEY (build_id)
Thomas Oulevey 98f397
) WITHOUT OIDS;
Thomas Oulevey 98f397
CREATE INDEX build_reservations_created ON build_reservations(created);
Thomas Oulevey 98f397
Thomas Oulevey 98f397
ALTER TABLE build ADD COLUMN cg_id INTEGER REFERENCES content_generator(id);
Thomas Oulevey 98f397
Thomas Oulevey 98f397
Thomas Oulevey 98f397
-- new indexes added in 1.18
Thomas Oulevey 98f397
CREATE INDEX tag_packages_active_tag_id ON tag_packages(active, tag_id);
Thomas Oulevey 98f397
CREATE INDEX tag_packages_create_event ON tag_packages(create_event);
Thomas Oulevey 98f397
CREATE INDEX tag_packages_revoke_event ON tag_packages(revoke_event);
Thomas Oulevey 98f397
CREATE INDEX tag_packages_owner ON tag_packages(owner);
Thomas Oulevey 98f397
Thomas Oulevey 98f397
Thomas Oulevey 98f397
COMMIT;