m160516_021255_admin_user.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. use yii\db\Migration;
  3. class m160516_021255_admin_user extends Migration
  4. {
  5. public function up()
  6. {
  7. $sql1 = "
  8. CREATE TABLE IF NOT EXISTS `admin_user` (
  9. `id` int(20) unsigned NOT NULL AUTO_INCREMENT,
  10. `username` varchar(50) DEFAULT NULL COMMENT '用户名',
  11. `password_hash` varchar(80) DEFAULT NULL COMMENT '密码',
  12. `password_reset_token` varchar(60) DEFAULT NULL COMMENT '密码token',
  13. `email` varchar(60) DEFAULT NULL COMMENT '邮箱',
  14. `person` varchar(100) DEFAULT NULL COMMENT '用户姓名',
  15. `code` varchar(100) DEFAULT NULL,
  16. `auth_key` varchar(60) DEFAULT NULL,
  17. `status` int(5) DEFAULT NULL COMMENT '状态',
  18. `created_at` int(18) DEFAULT NULL COMMENT '创建时间',
  19. `updated_at` int(18) DEFAULT NULL COMMENT '更新时间',
  20. `password` varchar(50) DEFAULT NULL COMMENT '密码',
  21. `access_token` varchar(60) DEFAULT NULL,
  22. `allowance` int(20) DEFAULT NULL,
  23. `allowance_updated_at` int(20) DEFAULT NULL,
  24. `created_at_datetime` datetime DEFAULT NULL,
  25. `updated_at_datetime` datetime DEFAULT NULL,
  26. `birth_date` datetime DEFAULT NULL COMMENT '出生日期',
  27. PRIMARY KEY (`id`),
  28. UNIQUE KEY `username` (`username`),
  29. UNIQUE KEY `access_token` (`access_token`)
  30. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
  31. ";
  32. $this->execute($sql1);
  33. $sql2 = "
  34. INSERT INTO `admin_user` (`id`, `username`, `password_hash`, `password_reset_token`, `email`, `person`, `code`, `auth_key`, `status`, `created_at`, `updated_at`, `password`, `access_token`, `allowance`, `allowance_updated_at`, `created_at_datetime`, `updated_at_datetime`, `birth_date`) VALUES
  35. (1, 'terry', '$2y$13$EyK1HyJtv4A/19Jb8gB5y.4SQm5y93eMeHjUf35ryLyd2dWPJlh8y', NULL, 'zqy234@126.com', '', '3333', 'HH-ZlZXirlG-egyz8OTtl9EVj9fvKW00', 1, 1441763620, 1467522167, '', 'yrYWR7kY-A9bUAP6UUZgCR3yi3ALtUh-', 599, 1452491877, '2016-01-12 09:41:44', '2016-07-03 13:02:47', NULL),
  36. (2, 'admin', '$2y$13$T5ZFrLpJdTEkAoAdnC6A/u8lh/pG.6M0qAZBo1lKE.6x6o3V6yvVG', NULL, '3727@qq.com', '超级管理员', '111', '_PYjb4PdIIY332LquBRC5tClZUXV0zm_', 1, NULL, 1468917063, '', '1Gk6ZNn-QaBaKFI4uE2bSw0w3N7ej72q', NULL, NULL, '2016-01-11 09:41:52', '2016-06-26 01:40:55', NULL);
  37. ";
  38. $this->execute($sql2);
  39. }
  40. public function down()
  41. {
  42. echo "m160516_021255_admin_user cannot be reverted.\n";
  43. return false;
  44. }
  45. /*
  46. // Use safeUp/safeDown to run migration code within a transaction
  47. public function safeUp()
  48. {
  49. }
  50. public function safeDown()
  51. {
  52. }
  53. */
  54. }