Created
March 28, 2014 18:31
-
-
Save schmunk42/9839772 to your computer and use it in GitHub Desktop.
Yii 2 User Extension Data Model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE TABLE `user` ( | |
| `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'The KEY obviously', | |
| `username` varchar(20) NOT NULL DEFAULT '' COMMENT 'Login name (alnum)', | |
| `email` varchar(128) NOT NULL DEFAULT '' COMMENT 'User e-mail address', | |
| `password` varchar(128) NOT NULL DEFAULT '' COMMENT 'Secure password hash', | |
| `auth_client` varchar(128) NOT NULL DEFAULT '' COMMENT 'Eg. local, LDAP, GitHub, Twitter, Facebook, ...', | |
| `auth_key` varchar(128) NOT NULL DEFAULT '' COMMENT 'External ID', | |
| `activation_key` varchar(128) NOT NULL DEFAULT '' COMMENT 'Key to activate the account, sent by email', | |
| `superuser` int(1) NOT NULL DEFAULT '0' COMMENT '** Not sure if needed, IMHO should be implemented in another way **', | |
| `status` int(1) NOT NULL DEFAULT '0' COMMENT 'Eg. registered,confirmed,activated,banned', | |
| `registered_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Timestamp of the registration', | |
| `last_login_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'Last login time', | |
| PRIMARY KEY (`id`), | |
| UNIQUE KEY `user_username` (`username`), | |
| UNIQUE KEY `user_email` (`email`), | |
| UNIQUE KEY `user_auth` (`auth_client`, `auth_key`) | |
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
Looks good. However, I agree with @nineinchnick, since superuser field is not needed (it could be a module param).
Also, I like the suggestion regarding the snetwork table.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
superuseris not needed andstatusshould be either flags or be split into more columns, becuase and account can have an confirmed/unconcirmed email and at the same time the admin can ban/unban it or it could get self-locked/unlocked in case of some events like failed login attempts.