m220227_143429_oauth2_authorization_code.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. use yii\db\Migration;
  3. class m220227_143429_oauth2_authorization_code extends Migration
  4. {
  5. public function up()
  6. {
  7. /* 取消外键约束 */
  8. $this->execute('SET foreign_key_checks = 0');
  9. /* 创建表 */
  10. $this->createTable('{{%oauth2_authorization_code}}', [
  11. 'authorization_code' => "varchar(100) NOT NULL",
  12. 'merchant_id' => "int(10) unsigned NULL DEFAULT '0' COMMENT '商户id'",
  13. 'store_id' => "int(10) unsigned NULL DEFAULT '0' COMMENT '店铺ID'",
  14. 'client_id' => "varchar(64) NOT NULL COMMENT '授权ID'",
  15. 'member_id' => "varchar(100) NULL COMMENT '用户ID'",
  16. 'redirect_uri' => "varchar(2000) NULL COMMENT '回调url'",
  17. 'expires' => "timestamp NOT NULL COMMENT '有效期'",
  18. 'scope' => "json NULL 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 (`authorization_code`)'
  23. ], "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='oauth2_授权回调code'");
  24. /* 索引设置 */
  25. $this->createIndex('authorization_code','{{%oauth2_authorization_code}}','authorization_code',0);
  26. /* 表数据 */
  27. /* 设置外键约束 */
  28. $this->execute('SET foreign_key_checks = 1;');
  29. }
  30. public function down()
  31. {
  32. $this->execute('SET foreign_key_checks = 0');
  33. /* 删除表 */
  34. $this->dropTable('{{%oauth2_authorization_code}}');
  35. $this->execute('SET foreign_key_checks = 1;');
  36. }
  37. }
粤ICP备19079148号