523 2.25 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
use strict;
use libdb;

sub DoUpdate($$$)
{
    my ($dbhandle, $dbname, $version) = @_;

    if (!DBSlotExists("apt_datasets", "gid")) {
        DBQueryFatal("alter table apt_datasets ".
		     " add `gid` varchar(32) NOT NULL default '' ".
		     "   after pid_idx, ".
		     " add `gid_idx` mediumint(8) unsigned NOT NULL default '0' ".
		     "   after gid");

	DBQueryFatal("update apt_datasets set gid=pid,gid_idx=pid_idx");
    }
    if (!DBSlotExists("apt_instance_failures", "gid")) {
        DBQueryFatal("alter table apt_instance_failures ".
		     " add `gid` varchar(32) NOT NULL default '' ".
		     "   after pid_idx, ".
		     " add `gid_idx` mediumint(8) unsigned NOT NULL default '0' ".
		     "   after gid");

	DBQueryFatal("update apt_instance_failures set gid=pid,gid_idx=pid_idx");
    }
    if (!DBSlotExists("apt_instance_history", "gid")) {
        DBQueryFatal("alter table apt_instance_history ".
		     " add `gid` varchar(32) NOT NULL default '' ".
		     "   after pid_idx, ".
		     " add `gid_idx` mediumint(8) unsigned NOT NULL default '0' ".
		     "   after gid");

	DBQueryFatal("update apt_instance_history set gid=pid,gid_idx=pid_idx");
    }
    if (!DBSlotExists("apt_instances", "gid")) {
        DBQueryFatal("alter table apt_instances ".
		     " add `gid` varchar(32) NOT NULL default '' ".
		     "   after pid_idx, ".
		     " add `gid_idx` mediumint(8) unsigned NOT NULL default '0' ".
		     "   after gid");

	DBQueryFatal("update apt_instances set gid=pid,gid_idx=pid_idx");
    }
    if (!DBSlotExists("apt_profile_versions", "gid")) {
        DBQueryFatal("alter table apt_profile_versions ".
		     " add `gid` varchar(32) NOT NULL default '' ".
		     "   after pid_idx, ".
		     " add `gid_idx` mediumint(8) unsigned NOT NULL default '0' ".
		     "   after gid");

	DBQueryFatal("update apt_profile_versions set gid=pid,gid_idx=pid_idx");
    }
    if (!DBSlotExists("apt_profiles", "gid")) {
        DBQueryFatal("alter table apt_profiles ".
		     " add `gid` varchar(32) NOT NULL default '' ".
		     "   after pid_idx, ".
		     " add `gid_idx` mediumint(8) unsigned NOT NULL default '0' ".
		     "   after gid");

	DBQueryFatal("update apt_profiles set gid=pid,gid_idx=pid_idx");
    }
    return 0;
}

# Local Variables:
# mode:perl
# End: