m160516_021204_admin_role.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. use yii\db\Migration;
  3. class m160516_021204_admin_role extends Migration
  4. {
  5. public function up()
  6. {
  7. $sql1 = "
  8. CREATE TABLE IF NOT EXISTS `admin_role` (
  9. `role_id` int(15) NOT NULL AUTO_INCREMENT,
  10. `role_name` varchar(100) CHARACTER SET utf8 DEFAULT NULL COMMENT '权限名字',
  11. `role_description` varchar(255) CHARACTER SET utf8 DEFAULT NULL COMMENT '权限描述',
  12. PRIMARY KEY (`role_id`)
  13. ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ;
  14. ";
  15. $this->execute($sql1);
  16. $sql2 = "
  17. INSERT INTO `admin_role` (`role_id`, `role_name`, `role_description`) VALUES
  18. (4, 'admin', '超级用户'),
  19. (12, '账户管理员', '账户管理员'),
  20. (13, 'ceshi', 'ceshi');
  21. ";
  22. $this->execute($sql2);
  23. }
  24. public function down()
  25. {
  26. echo "m160516_021204_admin_role cannot be reverted.\n";
  27. return false;
  28. }
  29. /*
  30. // Use safeUp/safeDown to run migration code within a transaction
  31. public function safeUp()
  32. {
  33. }
  34. public function safeDown()
  35. {
  36. }
  37. */
  38. }