Skip to content

Instantly share code, notes, and snippets.

@freiguy1
Last active August 29, 2015 13:57
Show Gist options
  • Save freiguy1/9555001 to your computer and use it in GitHub Desktop.
Save freiguy1/9555001 to your computer and use it in GitHub Desktop.
This is an initialization script for the securesocial user store. It does not contain a token table, because I kept that in memory, for now. Check out my blog post at http://ethanfrei.com/?p=336 for more info.
CREATE TABLE user (
userId INT AUTO_INCREMENT,
PRIMARY KEY(userId));
CREATE TABLE passwordInfo (
passwordInfoId INT AUTO_INCREMENT,
hasher VARCHAR(128) NOT NULL,
password VARCHAR(128) NOT NULL,
salt VARCHAR(128),
PRIMARY KEY(passwordInfoId));
CREATE TABLE oAuth1Info(
oAuth1InfoId INT AUTO_INCREMENT,
token VARCHAR(512) NOT NULL,
secret VARCHAR(512) NOT NULL,
PRIMARY KEY(oAuth1InfoId));
CREATE TABLE oAuth2Info(
oAuth2InfoId INT AUTO_INCREMENT,
accessToken VARCHAR(512) NOT NULL,
tokenType VARCHAR(128),
expiresIn INT,
refreshToken VARCHAR(128),
PRIMARY KEY(oAuth2InfoId));
CREATE TABLE identity (
providerId VARCHAR(64),
userSSId VARCHAR(64),
userId INT,
firstName VARCHAR(64) NOT NULL,
lastName VARCHAR(64) NOT NULL,
fullName VARCHAR(128) NOT NULL,
email VARCHAR(128),
avatarUrl VARCHAR(128),
oAuth1InfoId INT,
oAuth2InfoId INT,
passwordInfoId INT,
authenticationMethod VARCHAR(64),
PRIMARY KEY(providerId, userSSId),
FOREIGN KEY(userId) REFERENCES user(userId),
FOREIGN KEY(oAuth1InfoId) REFERENCES oAuth1Info(oAuth1InfoId),
FOREIGN KEY(oAuth2InfoId) REFERENCES oAuth2Info(oAuth2InfoId),
FOREIGN KEY(passwordInfoId) REFERENCES passwordInfo(passwordInfoId));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment