Files
yii2-usuario/tests/_data/schema.sql
2017-08-06 15:26:40 +02:00

81 lines
2.7 KiB
SQL

SET NAMES utf8;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for `profile`
-- ----------------------------
DROP TABLE IF EXISTS `profile`;
CREATE TABLE `profile` (
`user_id` int(11) NOT NULL,
`name` varchar(255) DEFAULT NULL,
`public_email` varchar(255) DEFAULT NULL,
`gravatar_email` varchar(255) DEFAULT NULL,
`gravatar_id` varchar(32) DEFAULT NULL,
`location` varchar(255) DEFAULT NULL,
`website` varchar(255) DEFAULT NULL,
`timezone` varchar(40) DEFAULT NULL,
`bio` text,
PRIMARY KEY (`user_id`),
CONSTRAINT `fk_user_profile` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for `social_account`
-- ----------------------------
DROP TABLE IF EXISTS `social_account`;
CREATE TABLE `social_account` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) DEFAULT NULL,
`provider` varchar(255) NOT NULL,
`client_id` varchar(255) NOT NULL,
`code` varchar(32) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
`username` varchar(255) DEFAULT NULL,
`data` text,
`created_at` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `account_unique` (`provider`,`client_id`),
UNIQUE KEY `account_unique_code` (`code`),
KEY `fk_user_account` (`user_id`),
CONSTRAINT `fk_user_account` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for `token`
-- ----------------------------
DROP TABLE IF EXISTS `token`;
CREATE TABLE `token` (
`user_id` int(11) NOT NULL,
`code` varchar(32) NOT NULL,
`type` smallint(6) NOT NULL,
`created_at` int(11) NOT NULL,
UNIQUE KEY `token_unique` (`user_id`,`code`,`type`),
CONSTRAINT `fk_user_token` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for `user`
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`password_hash` varchar(60) NOT NULL,
`auth_key` varchar(32) NOT NULL,
`unconfirmed_email` varchar(255) DEFAULT NULL,
`registration_ip` varchar(45) DEFAULT NULL,
`confirmed_at` int(11) DEFAULT NULL,
`blocked_at` int(11) DEFAULT NULL,
`created_at` int(11) NOT NULL,
`updated_at` int(11) NOT NULL,
`flags` int(11) NOT NULL DEFAULT '0',
`last_login_at` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `user_unique_email` (`email`),
UNIQUE KEY `user_unique_username` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
SET FOREIGN_KEY_CHECKS = 1;