Lots of table fixes

This commit is contained in:
Alex Bilbie 2013-04-28 23:56:17 +01:00
parent d0d0d2a7c3
commit a93a039df3

View File

@ -16,51 +16,48 @@ CREATE TABLE `oauth_client_endpoints` (
CONSTRAINT `f_oaclen_clid` FOREIGN KEY (`client_id`) REFERENCES `oauth_clients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE CONSTRAINT `f_oaclen_clid` FOREIGN KEY (`client_id`) REFERENCES `oauth_clients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=INNODB DEFAULT CHARSET=utf8; ) ENGINE=INNODB DEFAULT CHARSET=utf8;
CREATE TABLE `oauth_session` ( CREATE TABLE `oauth_sessions` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`client_id` CHAR(40) NOT NULL, `client_id` char(40) NOT NULL,
`owner_type` ENUM('user','client') NOT NULL DEFAULT 'user', `owner_type` enum('user','client') NOT NULL DEFAULT 'user',
`owner_id` VARCHAR(255) NOT NULL, `owner_id` varchar(255) NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `i_uase_clid_owty_owid` (`client_id`,`owner_type`,`owner_id`), KEY `i_uase_clid_owty_owid` (`client_id`,`owner_type`,`owner_id`),
CONSTRAINT `f_oase_clid` FOREIGN KEY (`client_id`) REFERENCES `oauth_clients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE CONSTRAINT `f_oase_clid` FOREIGN KEY (`client_id`) REFERENCES `oauth_clients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=INNODB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `oauth_session_access_token` ( CREATE TABLE `oauth_session_access_tokens` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`session_id` INT(10) UNSIGNED NOT NULL, `session_id` int(10) unsigned NOT NULL,
`access_token` CHAR(40) CHARACTER SET utf8 NOT NULL DEFAULT '', `access_token` char(40) NOT NULL DEFAULT '',
`access_token_expires` INT(10) UNSIGNED NOT NULL, `access_token_expires` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `u_oaseacto_acto_seid` (`access_token`,`session_id`), UNIQUE KEY `u_oaseacto_acto_seid` (`access_token`,`session_id`),
KEY `f_oaseto_seid` (`session_id`), KEY `f_oaseto_seid` (`session_id`),
CONSTRAINT `f_oaseto_seid` FOREIGN KEY (`session_id`) REFERENCES `oauth_session` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION CONSTRAINT `f_oaseto_seid` FOREIGN KEY (`session_id`) REFERENCES `oauth_sessions` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=INNODB DEFAULT CHARSET=utf8;
CREATE TABLE `oauth_session_authcode` (
`session_id` INT(10) UNSIGNED NOT NULL,
`session_access_token_id` INT(10) UNSIGNED DEFAULT NULL,
`auth_code` CHAR(40) CHARACTER SET utf8 NOT NULL DEFAULT '',
`auth_code_expires` INT(10) UNSIGNED NOT NULL,
PRIMARY KEY (`session_id`),
KEY `f_oaseau_setoid` (`session_access_token_id`),
CONSTRAINT `f_oaseau_seid` FOREIGN KEY (`session_id`) REFERENCES `oauth_session` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT `f_oaseau_setoid` FOREIGN KEY (`session_access_token_id`) REFERENCES `oauth_session_access_token` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `oauth_session_redirect` ( CREATE TABLE `oauth_session_authcodes` (
`session_id` INT(10) UNSIGNED NOT NULL, `session_id` int(10) unsigned NOT NULL,
`redirect_uri` VARCHAR(255) CHARACTER SET utf8 NOT NULL DEFAULT '', `auth_code` char(40) NOT NULL DEFAULT '',
`auth_code_expires` int(10) unsigned NOT NULL,
PRIMARY KEY (`session_id`), PRIMARY KEY (`session_id`),
CONSTRAINT `f_oasere_seid` FOREIGN KEY (`session_id`) REFERENCES `oauth_session` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION CONSTRAINT `f_oaseau_seid` FOREIGN KEY (`session_id`) REFERENCES `oauth_sessions` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=INNODB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `oauth_session_refresh_token` ( CREATE TABLE `oauth_session_redirects` (
`session_access_token_id` INT(10) UNSIGNED NOT NULL, `session_id` int(10) unsigned NOT NULL,
`refresh_token` CHAR(40) CHARACTER SET utf8 NOT NULL DEFAULT '', `redirect_uri` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`session_id`),
CONSTRAINT `f_oasere_seid` FOREIGN KEY (`session_id`) REFERENCES `oauth_sessions` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `oauth_session_refresh_tokens` (
`session_access_token_id` int(10) unsigned NOT NULL,
`refresh_token` char(40) NOT NULL DEFAULT '',
PRIMARY KEY (`session_access_token_id`), PRIMARY KEY (`session_access_token_id`),
CONSTRAINT `f_oasetore_setoid` FOREIGN KEY (`session_access_token_id`) REFERENCES `oauth_session_access_token` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION CONSTRAINT `f_oasetore_setoid` FOREIGN KEY (`session_access_token_id`) REFERENCES `oauth_session_access_tokens` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=INNODB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `oauth_scopes` ( CREATE TABLE `oauth_scopes` (
`id` SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT, `id` SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
@ -71,13 +68,13 @@ CREATE TABLE `oauth_scopes` (
UNIQUE KEY `u_oasc_sc` (`key`) UNIQUE KEY `u_oasc_sc` (`key`)
) ENGINE=INNODB DEFAULT CHARSET=utf8; ) ENGINE=INNODB DEFAULT CHARSET=utf8;
CREATE TABLE `oauth_session_token_scope` ( CREATE TABLE `oauth_session_token_scopes` (
`session_token_scope_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, `session_token_scope_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`session_access_token_id` INT(10) UNSIGNED NOT NULL, `session_access_token_id` int(10) unsigned DEFAULT NULL,
`scope_id` SMALLINT(5) UNSIGNED NOT NULL, `scope_id` smallint(5) unsigned NOT NULL,
PRIMARY KEY (`session_token_scope_id`), PRIMARY KEY (`session_token_scope_id`),
UNIQUE KEY `u_setosc_setoid_scid` (`session_access_token_id`,`scope_id`), UNIQUE KEY `u_setosc_setoid_scid` (`session_access_token_id`,`scope_id`),
KEY `f_oasetosc_scid` (`scope_id`), KEY `f_oasetosc_scid` (`scope_id`),
CONSTRAINT `f_oasetosc_setoid` FOREIGN KEY (`session_access_token_id`) REFERENCES `oauth_session_access_token` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `f_oasetosc_scid` FOREIGN KEY (`scope_id`) REFERENCES `oauth_scopes` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT `f_oasetosc_scid` FOREIGN KEY (`scope_id`) REFERENCES `oauth_scopes` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION CONSTRAINT `f_oasetosc_setoid` FOREIGN KEY (`session_access_token_id`) REFERENCES `oauth_session_access_tokens` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=INNODB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;