m220227_143426_api_access_token.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. use yii\db\Migration;
  3. class m220227_143426_api_access_token extends Migration
  4. {
  5. public function up()
  6. {
  7. /* 取消外键约束 */
  8. $this->execute('SET foreign_key_checks = 0');
  9. /* 创建表 */
  10. $this->createTable('{{%api_access_token}}', [
  11. 'id' => "int(10) unsigned NOT NULL AUTO_INCREMENT",
  12. 'merchant_id' => "int(10) unsigned NULL DEFAULT '0' COMMENT '商户id'",
  13. 'store_id' => "int(10) unsigned NULL DEFAULT '0' COMMENT '店铺ID'",
  14. 'refresh_token' => "varchar(60) NULL DEFAULT '' COMMENT '刷新令牌'",
  15. 'access_token' => "varchar(60) NULL DEFAULT '' COMMENT '授权令牌'",
  16. 'member_id' => "int(10) unsigned NULL DEFAULT '0' COMMENT '用户id'",
  17. 'member_type' => "tinyint(4) NULL DEFAULT '1' COMMENT '用户类型'",
  18. 'group' => "varchar(100) NULL DEFAULT '' COMMENT '组别'",
  19. 'status' => "tinyint(4) NULL DEFAULT '1' COMMENT '状态[-1:删除;0:禁用;1启用]'",
  20. 'created_at' => "int(10) unsigned NULL DEFAULT '0' COMMENT '创建时间'",
  21. 'updated_at' => "int(10) unsigned NULL DEFAULT '0' COMMENT '修改时间'",
  22. 'PRIMARY KEY (`id`)'
  23. ], "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='api_授权秘钥表'");
  24. /* 索引设置 */
  25. $this->createIndex('access_token','{{%api_access_token}}','access_token',1);
  26. $this->createIndex('refresh_token','{{%api_access_token}}','refresh_token',1);
  27. $this->createIndex('member_id','{{%api_access_token}}','member_id, member_type, group',0);
  28. $this->createIndex('merchant_id','{{%api_access_token}}','merchant_id',0);
  29. /* 表数据 */
  30. /* 设置外键约束 */
  31. $this->execute('SET foreign_key_checks = 1;');
  32. }
  33. public function down()
  34. {
  35. $this->execute('SET foreign_key_checks = 0');
  36. /* 删除表 */
  37. $this->dropTable('{{%api_access_token}}');
  38. $this->execute('SET foreign_key_checks = 1;');
  39. }
  40. }
粤ICP备19079148号