m220227_143428_member_auth.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. use yii\db\Migration;
  3. class m220227_143428_member_auth extends Migration
  4. {
  5. public function up()
  6. {
  7. /* 取消外键约束 */
  8. $this->execute('SET foreign_key_checks = 0');
  9. /* 创建表 */
  10. $this->createTable('{{%member_auth}}', [
  11. 'id' => "int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键'",
  12. 'merchant_id' => "int(10) unsigned NULL DEFAULT '0' COMMENT '商户id'",
  13. 'store_id' => "int(10) unsigned NULL DEFAULT '0' COMMENT '店铺ID'",
  14. 'member_id' => "int(10) unsigned NULL DEFAULT '0' COMMENT '用户id'",
  15. 'member_type' => "tinyint(4) NULL DEFAULT '1' COMMENT '1:会员;2:后台管理员;3:商家管理员'",
  16. 'unionid' => "varchar(64) NULL DEFAULT '' COMMENT '唯一ID'",
  17. 'oauth_client' => "varchar(20) NULL DEFAULT '' COMMENT '授权组别'",
  18. 'oauth_client_user_id' => "varchar(100) NULL DEFAULT '' COMMENT '授权id'",
  19. 'gender' => "tinyint(4) unsigned NULL DEFAULT '0' COMMENT '性别[0:未知;1:男;2:女]'",
  20. 'nickname' => "varchar(100) NULL DEFAULT '' COMMENT '昵称'",
  21. 'head_portrait' => "varchar(200) NULL DEFAULT '' COMMENT '头像'",
  22. 'birthday' => "date NULL COMMENT '生日'",
  23. 'country' => "varchar(100) NULL DEFAULT '' COMMENT '国家'",
  24. 'province' => "varchar(100) NULL DEFAULT '' COMMENT '省'",
  25. 'city' => "varchar(100) NULL DEFAULT '' COMMENT '市'",
  26. 'is_addon' => "tinyint(4) unsigned NULL DEFAULT '0' COMMENT '是否插件'",
  27. 'addon_name' => "varchar(200) NULL DEFAULT '' COMMENT '插件名称'",
  28. 'status' => "tinyint(4) NULL DEFAULT '1' COMMENT '状态(-1:已删除,0:禁用,1:正常)'",
  29. 'created_at' => "int(10) unsigned NULL DEFAULT '0' COMMENT '创建时间'",
  30. 'updated_at' => "int(10) unsigned NULL DEFAULT '0' COMMENT '修改时间'",
  31. 'PRIMARY KEY (`id`)'
  32. ], "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员_第三方授权'");
  33. /* 索引设置 */
  34. $this->createIndex('oauth_client','{{%member_auth}}','oauth_client, oauth_client_user_id',0);
  35. $this->createIndex('member_id','{{%member_auth}}','member_id',0);
  36. /* 表数据 */
  37. /* 设置外键约束 */
  38. $this->execute('SET foreign_key_checks = 1;');
  39. }
  40. public function down()
  41. {
  42. $this->execute('SET foreign_key_checks = 0');
  43. /* 删除表 */
  44. $this->dropTable('{{%member_auth}}');
  45. $this->execute('SET foreign_key_checks = 1;');
  46. }
  47. }
粤ICP备19079148号