From b5b015ce524157cfef4b795e4b0c7ff17b4d0fe2 Mon Sep 17 00:00:00 2001
From: Barry Warsaw
Date: Fri, 22 Apr 2011 19:26:43 -0400
Subject: Give IMembers a unique member id.  We have to do this in order to
 give them a path at the root of the resource tree (i.e. /members/X) and
 because when members can be subscribed by their IUser record (for preferred
 address), their canonical location cannot contain the address they are
 subscribed with.  When their preferred address changes (without otherwise
 touching their membership), this address will change and that's not good for
 a canonical location.

Other changes:

* Added IMember.member_id attribute
* Added ISubscriptionService.get_member() so member records can be retrieve by
  member id.
* We can now get individual members by id via the REST API.
* Extend the UniqueIDFactory so that it can take a 'context' (defaulting to
  None).  The context is only used in the testing infrastructure so that
  separate files can be used for user ids and member ids.  Otherwise, we'd
  have gaps in those sequences.
* When *not* in testing mode, ensure that UIDs cannot be reused by keeping a
  table of all UIDs ever handed out.  We *should* never get collisions, but
  this ensures it.
* Clean up mailman.sql
---
 src/mailman/database/mailman.sql | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

(limited to 'src/mailman/database/mailman.sql')

diff --git a/src/mailman/database/mailman.sql b/src/mailman/database/mailman.sql
index 5af8656c2..deb266297 100644
--- a/src/mailman/database/mailman.sql
+++ b/src/mailman/database/mailman.sql
@@ -19,8 +19,7 @@ CREATE TABLE acceptablealias (
     );
 CREATE INDEX ix_acceptablealias_mailing_list_id
     ON acceptablealias (mailing_list_id);
-CREATE INDEX ix_acceptablealias_alias
-    ON acceptablealias ("alias");
+CREATE INDEX ix_acceptablealias_alias ON acceptablealias ("alias");
 
 CREATE TABLE address (
     id INTEGER NOT NULL,
@@ -197,6 +196,7 @@ CREATE TABLE mailinglist (
 
 CREATE TABLE member (
     id INTEGER NOT NULL,
+    _member_id TEXT,
     role TEXT,
     mailing_list TEXT,
     moderation_action INTEGER,
@@ -211,6 +211,9 @@ CREATE TABLE member (
     CONSTRAINT member_user_id_fk
         FOREIGN KEY (user_id) REFERENCES user (id)
     );
+CREATE INDEX ix_member__member_id ON member (_member_id);
+CREATE INDEX ix_member_address_id ON member (address_id);
+CREATE INDEX ix_member_preferences_id ON member (preferences_id);
 
 CREATE TABLE message (
     id INTEGER NOT NULL,
@@ -287,8 +290,6 @@ CREATE TABLE version (
 CREATE INDEX ix__request_mailing_list_id ON _request (mailing_list_id);
 CREATE INDEX ix_address_preferences_id ON address (preferences_id);
 CREATE INDEX ix_address_user_id ON address (user_id);
-CREATE INDEX ix_member_address_id ON member (address_id);
-CREATE INDEX ix_member_preferences_id ON member (preferences_id);
 CREATE INDEX ix_pendedkeyvalue_pended_id ON pendedkeyvalue (pended_id);
 CREATE INDEX ix_user_preferences_id ON user (preferences_id);
 
@@ -298,3 +299,11 @@ CREATE TABLE ban (
     mailing_list TEXT,
     PRIMARY KEY (id)
     );
+
+CREATE TABLE uid (
+    -- Keep track of all assigned unique ids to prevent re-use.
+    id INTEGER NOT NULL,
+    uid TEXT,
+    PRIMARY KEY (id)
+    );
+CREATE INDEX ix_uid_uid ON uid (uid);
\ No newline at end of file
-- 
cgit v1.3.1

