Changeset 3267 for trunk/modules/auth/views
- Timestamp:
- 08/05/2008 10:44:02 PM (4 months ago)
- Files:
-
- 1 modified
-
trunk/modules/auth/views/auth/install.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/auth/views/auth/install.php
r2441 r3267 1 < p>The following tables must be installed in your database: users, roles, and users_roles. If you have not already installed these tables, please run the following query:</p>1 <div class="box"> 2 2 3 <pre> 3 <p>The following tables must be installed in your database: <code>users</code>, <code>roles</code>, <code>roles_users</code>, and <code>user_tokens</code>. If you have not already installed these tables, please run the installation query below.</p> 4 5 <p>After the tables have been installed, <?php echo html::anchor('auth_demo/create', 'create a user') ?>.</p> 6 7 <p><em>This query is MySQL-specific, but should be easy to adapt to an database that supports foreign keys.</em></p> 8 9 <?php echo form::textarea('query', <<<EOF 4 10 CREATE TABLE IF NOT EXISTS `roles` ( 5 11 `id` int(11) unsigned NOT NULL auto_increment, … … 8 14 PRIMARY KEY (`id`), 9 15 UNIQUE KEY `uniq_name` (`name`) 10 ) ENGINE= MyISAMDEFAULT CHARSET=utf8;16 ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 11 17 12 18 INSERT INTO `roles` (`id`, `name`, `description`) VALUES(1, 'login', 'Login privileges, granted after account confirmation'); 13 19 INSERT INTO `roles` (`id`, `name`, `description`) VALUES(2, 'admin', 'Administrative user, has access to everything.'); 20 21 CREATE TABLE IF NOT EXISTS `roles_users` ( 22 `user_id` int(10) unsigned NOT NULL, 23 `role_id` int(10) unsigned NOT NULL, 24 PRIMARY KEY (`user_id`,`role_id`), 25 KEY `fk_role_id` (`role_id`) 26 ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 14 27 15 28 CREATE TABLE IF NOT EXISTS `users` ( … … 23 36 UNIQUE KEY `uniq_username` (`username`), 24 37 UNIQUE KEY `uniq_email` (`email`) 25 ) ENGINE=MyISAM DEFAULT CHARSET=utf8; 26 27 CREATE TABLE IF NOT EXISTS `users_roles` ( 28 `user_id` int(10) unsigned NOT NULL, 29 `role_id` int(10) unsigned NOT NULL, 30 PRIMARY KEY (`user_id`,`role_id`) 31 ) ENGINE=MyISAM DEFAULT CHARSET=utf8; 38 ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 32 39 33 40 CREATE TABLE IF NOT EXISTS `user_tokens` ( … … 39 46 `expires` int(10) unsigned NOT NULL, 40 47 PRIMARY KEY (`id`), 41 UNIQUE KEY `uniq_token` (`token`) 42 ) ENGINE=MyISAM DEFAULT CHARSET=utf8; 43 </pre> 48 UNIQUE KEY `uniq_token` (`token`), 49 KEY `fk_user_id` (`user_id`) 50 ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 44 51 45 <p>After the tables have been installed, <?php echo html::anchor('auth_demo/create', 'create a user') ?>.</p> 52 ALTER TABLE `roles_users` 53 ADD CONSTRAINT `roles_users_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE, 54 ADD CONSTRAINT `roles_users_ibfk_2` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE; 55 56 ALTER TABLE `user_tokens` 57 ADD CONSTRAINT `user_tokens_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE; 58 EOF 59 , 'style="width:90%;height:30em;padding:0.5em"') ?> 60 61 </div>
