From 3d6a0f730d153378f47805bc6ea8a8d543eb9ab6 Mon Sep 17 00:00:00 2001
From: Zach Copley <zach@status.net>
Date: Wed, 20 Oct 2010 11:41:04 -0700
Subject: [PATCH] Revert DB change for OAuth. Change compound key for
 oauth_application_user back to (profile_id, application_id). I think we can
 get away without a DB change by only issuing one anonymous access token per
 user.

---
 classes/Oauth_application_user.php | 2 +-
 classes/statusnet.ini              | 3 +--
 db/statusnet.sql                   | 4 ++--
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/classes/Oauth_application_user.php b/classes/Oauth_application_user.php
index fcf6553ffe..e1b4b8c046 100644
--- a/classes/Oauth_application_user.php
+++ b/classes/Oauth_application_user.php
@@ -13,7 +13,7 @@ class Oauth_application_user extends Memcached_DataObject
     public $profile_id;                      // int(4)  primary_key not_null
     public $application_id;                  // int(4)  primary_key not_null
     public $access_type;                     // tinyint(1)
-    public $token;                           // varchar(255) primary_key not_null
+    public $token;                           // varchar(255)
     public $created;                         // datetime   not_null
     public $modified;                        // timestamp   not_null default_CURRENT_TIMESTAMP
 
diff --git a/classes/statusnet.ini b/classes/statusnet.ini
index 7aa115fecd..3fb8ee208b 100644
--- a/classes/statusnet.ini
+++ b/classes/statusnet.ini
@@ -393,14 +393,13 @@ name = U
 profile_id = 129
 application_id = 129
 access_type = 17
-token = 130
+token = 2
 created = 142
 modified = 384
 
 [oauth_application_user__keys]
 profile_id = K
 application_id = K
-token = K
 
 [profile]
 id = 129
diff --git a/db/statusnet.sql b/db/statusnet.sql
index 4ae7e56841..3f95948e1e 100644
--- a/db/statusnet.sql
+++ b/db/statusnet.sql
@@ -231,10 +231,10 @@ create table oauth_application_user (
     profile_id integer not null comment 'user of the application' references profile (id),
     application_id integer not null comment 'id of the application' references oauth_application (id),
     access_type tinyint default 0 comment 'access type, bit 1 = read, bit 2 = write',
-    token varchar(255) not null comment 'request or access token',
+    token varchar(255) comment 'request or access token',
     created datetime not null comment 'date this record was created',
     modified timestamp comment 'date this record was modified',
-    constraint primary key (profile_id, application_id, token)
+    constraint primary key (profile_id, application_id)
 ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;
 
 /* These are used by JanRain OpenID library */
-- 
2.39.5