head	1.5;
access;
symbols;
locks; strict;
comment	@# @;


1.5
date	2001.07.10.22.52.15;	author kmaples;	state dead;
branches;
next	1.4;

1.4
date	2001.06.28.22.38.31;	author kmaples;	state Exp;
branches;
next	1.3;

1.3
date	2001.06.20.22.11.40;	author kmaples;	state Exp;
branches;
next	1.2;

1.2
date	2001.06.15.22.00.59;	author kmaples;	state Exp;
branches;
next	1.1;

1.1
date	2001.06.15.00.21.57;	author kmaples;	state Exp;
branches;
next	;


desc
@@


1.5
log
@IZ work previously projected for 1.1.x release is now targeted for 1.2.x
release.  Moving the upgrade scripts accordingly.
@
text
@# $Id: IzProfilesGroups.sql,v 1.4 2001/06/28 22:38:31 kmaples Exp $

# Create new lookup table joining profiles and groups:

CREATE TABLE profiles_x_groups (
    userid   mediumint(9)               NOT NULL,
    groupid  mediumint(9)               NOT NULL,
    canbless tinyint(4)     DEFAULT '0' NOT NULL,
    
    PRIMARY KEY (userid, groupid)
);

# Create new lookup table joining issues and groups:

CREATE TABLE issues_x_groups (
    issue_id   mediumint(9)               NOT NULL,
    groupid    mediumint(9)               NOT NULL,
    
    PRIMARY KEY (issue_id, groupid)
);

# Temporary table for new groups data:

CREATE TABLE new_groups (
  groupid      mediumint(9) DEFAULT '0' NOT NULL auto_increment,
  name         varchar(255) DEFAULT ''  NOT NULL,
  description  text                     NOT NULL,
  isissuegroup tinyint(4)   DEFAULT '0' NOT NULL,
  userregexp   tinytext                 NOT NULL,
  
  PRIMARY KEY (groupid),
  UNIQUE (name)
);

# Extract data from groups table:

INSERT INTO new_groups 
SELECT NULL, name, description, isissuegroup, userregexp 
FROM groups;

# Populate the lookup tables from old groups table:

INSERT INTO profiles_x_groups 
SELECT profiles.userid, new_groups.groupid, 
    profiles.groupset & profiles.blessgroupset & groups.bit != 0    
FROM   profiles, new_groups, groups
WHERE  profiles.groupset & groups.bit != 0 
AND    groups.name = new_groups.name;

INSERT INTO issues_x_groups
SELECT issues.issue_id, new_groups.groupid
FROM   issues, new_groups, groups
WHERE  issues.groupset & groups.bit != 0
AND    groups.name = new_groups.name;

# Switch new table for old table:

DROP TABLE groups;
ALTER TABLE new_groups RENAME AS groups;

# Cleanup unneeded fields:

ALTER TABLE profiles DROP COLUMN groupset;
ALTER TABLE profiles DROP COLUMN blessgroupset;
ALTER TABLE issues   DROP COLUMN groupset; 



@


1.4
log
@group 'name' column must be unique.
@
text
@d1 1
a1 1
# $Id: IzProfilesGroups.sql,v 1.3 2001/06/20 22:11:40 kmaples Exp $
@


1.3
log
@Added issues-to-groups lookup table to decouple issues from group membership.
@
text
@d1 1
a1 1
# $Id: IzProfilesGroups.sql,v 1.2 2001/06/15 22:00:59 kmaples Exp $
d31 2
a32 1
  PRIMARY KEY (groupid)
@


1.2
log
@sql to create and populate new groups tables
@
text
@d1 1
a1 1
# $Id: IzProfilesGroups.sql,v 1.1 2001/06/15 00:21:57 kmaples Exp $
d3 1
a3 1
# Create new lookup table:
d13 9
d40 1
a40 1
# Populate the lookup table from old groups table:
d49 6
d64 1
a64 1

@


1.1
log
@Migrating Iz's permissioning away from bitmasks and toward lookup tables.
@
text
@d1 3
a3 1
# $Id: $
d6 3
a8 3
    userid   mediumint(9)             NOT NULL,
    groupid  mediumint(9)             NOT NULL,
    canbless tinyint(4)   DEFAULT '0' NOT NULL,
d12 41
@

