From 77399232732f162b688562f88380144b6a7f678f Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Tue, 12 Feb 2013 20:33:03 +0000 Subject: [PATCH] Updated database --- sql/database.sql | 77 ++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 42 deletions(-) diff --git a/sql/database.sql b/sql/database.sql index e733253b..e2e31c8e 100644 --- a/sql/database.sql +++ b/sql/database.sql @@ -1,5 +1,13 @@ --- Create syntax for TABLE 'clients' -CREATE TABLE `clients` ( +CREATE TABLE `oauth_client_endpoints` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `client_id` varchar(40) NOT NULL DEFAULT '', + `redirect_uri` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `client_id` (`client_id`), + CONSTRAINT `oauth_client_endpoints_ibfk_1` FOREIGN KEY (`client_id`) REFERENCES `oauth_clients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `oauth_clients` ( `id` varchar(40) NOT NULL DEFAULT '', `secret` varchar(40) NOT NULL DEFAULT '', `name` varchar(255) NOT NULL DEFAULT '', @@ -7,45 +15,6 @@ CREATE TABLE `clients` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- Create syntax for TABLE 'client_endpoints' -CREATE TABLE `client_endpoints` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `client_id` varchar(40) NOT NULL DEFAULT '', - `redirect_uri` varchar(255) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `client_id` (`client_id`), - CONSTRAINT `client_endpoints_ibfk_1` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - --- Create syntax for TABLE 'oauth_sessions' -CREATE TABLE `oauth_sessions` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `client_id` varchar(40) NOT NULL DEFAULT '', - `redirect_uri` varchar(250) DEFAULT '', - `owner_type` enum('user','client') NOT NULL DEFAULT 'user', - `owner_id` varchar(255) DEFAULT NULL, - `auth_code` varchar(40) DEFAULT '', - `access_token` varchar(40) DEFAULT '', - `refresh_token` varchar(40) NOT NULL, - `access_token_expires` int(10) DEFAULT NULL, - `stage` enum('requested','granted') NOT NULL DEFAULT 'requested', - `first_requested` int(10) unsigned NOT NULL, - `last_updated` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`), - KEY `client_id` (`client_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - --- Create syntax for TABLE 'scopes' -CREATE TABLE `scopes` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `scope` varchar(255) NOT NULL DEFAULT '', - `name` varchar(255) NOT NULL DEFAULT '', - `description` varchar(255) DEFAULT '', - PRIMARY KEY (`id`), - UNIQUE KEY `scope` (`scope`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - --- Create syntax for TABLE 'oauth_session_scopes' CREATE TABLE `oauth_session_scopes` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `session_id` int(11) unsigned NOT NULL, @@ -53,6 +22,30 @@ CREATE TABLE `oauth_session_scopes` ( PRIMARY KEY (`id`), KEY `session_id` (`session_id`), KEY `scope_id` (`scope_id`), - CONSTRAINT `oauth_session_scopes_ibfk_5` FOREIGN KEY (`scope_id`) REFERENCES `scopes` (`id`) ON DELETE CASCADE, + CONSTRAINT `oauth_session_scopes_ibfk_5` FOREIGN KEY (`scope_id`) REFERENCES `oauth_scopes` (`id`) ON DELETE CASCADE, CONSTRAINT `oauth_session_scopes_ibfk_4` FOREIGN KEY (`session_id`) REFERENCES `oauth_sessions` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `oauth_sessions` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `client_id` varchar(40) NOT NULL DEFAULT '', + `redirect_uri` varchar(250) DEFAULT '', + `owner_type` enum('user','client') NOT NULL DEFAULT 'user', + `owner_id` varchar(255) DEFAULT '', + `auth_code` varchar(40) DEFAULT '', + `access_token` varchar(40) DEFAULT '', + `refresh_token` varchar(40) DEFAULT '', + `access_token_expires` int(10) DEFAULT NULL, + `stage` enum('requested','granted') NOT NULL DEFAULT 'requested', + PRIMARY KEY (`id`), + KEY `client_id` (`client_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `oauth_scopes` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `scope` varchar(255) NOT NULL DEFAULT '', + `name` varchar(255) NOT NULL DEFAULT '', + `description` varchar(255) DEFAULT '', + PRIMARY KEY (`id`), + UNIQUE KEY `scope` (`scope`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; \ No newline at end of file