install.sql 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. CREATE TABLE IF NOT EXISTS `bx_oauth_access_tokens` (
  2. `access_token` varchar(40) NOT NULL,
  3. `client_id` varchar(80) NOT NULL,
  4. `user_id` int(10) unsigned DEFAULT NULL,
  5. `expires` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  6. `scope` varchar(255) DEFAULT NULL,
  7. PRIMARY KEY (`access_token`)
  8. );
  9. CREATE TABLE IF NOT EXISTS `bx_oauth_authorization_codes` (
  10. `authorization_code` varchar(40) NOT NULL,
  11. `client_id` varchar(80) NOT NULL,
  12. `user_id` int(10) unsigned DEFAULT NULL,
  13. `redirect_uri` varchar(255) DEFAULT NULL,
  14. `expires` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  15. `scope` varchar(255) DEFAULT NULL,
  16. PRIMARY KEY (`authorization_code`),
  17. KEY `user_id` (`user_id`)
  18. );
  19. CREATE TABLE IF NOT EXISTS `bx_oauth_clients` (
  20. `id` int(11) NOT NULL AUTO_INCREMENT,
  21. `title` varchar(255) NOT NULL,
  22. `client_id` varchar(80) NOT NULL,
  23. `client_secret` varchar(80) DEFAULT NULL,
  24. `redirect_uri` varchar(255) NOT NULL,
  25. `grant_types` varchar(80) DEFAULT NULL,
  26. `scope` varchar(255) DEFAULT NULL,
  27. `parent_id` int(10) unsigned DEFAULT 0,
  28. `user_id` int(10) unsigned DEFAULT 0,
  29. PRIMARY KEY (`id`),
  30. UNIQUE KEY `client_id` (`client_id`)
  31. );
  32. CREATE TABLE IF NOT EXISTS `bx_oauth_allowed_origins` (
  33. `id` int(11) NOT NULL AUTO_INCREMENT,
  34. `client_id` int(11) NOT NULL,
  35. `url` varchar(255) NOT NULL,
  36. PRIMARY KEY (`id`),
  37. KEY `url` (`url`(191))
  38. );
  39. CREATE TABLE IF NOT EXISTS `bx_oauth_refresh_tokens` (
  40. `refresh_token` varchar(40) NOT NULL,
  41. `client_id` varchar(80) NOT NULL,
  42. `user_id` int(10) unsigned DEFAULT NULL,
  43. `expires` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  44. `scope` varchar(255) DEFAULT NULL,
  45. PRIMARY KEY (`refresh_token`),
  46. KEY `user_id` (`user_id`)
  47. );
  48. CREATE TABLE IF NOT EXISTS `bx_oauth_scopes` (
  49. `id` int(11) NOT NULL AUTO_INCREMENT,
  50. `scope` varchar(255) DEFAULT NULL,
  51. `is_default` tinyint(1) DEFAULT NULL,
  52. PRIMARY KEY (`id`)
  53. );
  54. INSERT INTO `bx_oauth_scopes` (`scope`, `is_default`) VALUES
  55. ('basic', 1),
  56. ('service', 0),
  57. ('market', 0);
  58. -- Studio page and widget
  59. INSERT INTO `sys_std_pages`(`index`, `name`, `header`, `caption`, `icon`) VALUES
  60. (3, 'bx_oauth', '_bx_oauth', '_bx_oauth', 'bx_oauth@modules/boonex/oauth2/|std-icon.svg');
  61. SET @iPageId = LAST_INSERT_ID();
  62. SET @iParentPageId = (SELECT `id` FROM `sys_std_pages` WHERE `name` = 'home');
  63. SET @iParentPageOrder = (SELECT MAX(`order`) FROM `sys_std_pages_widgets` WHERE `page_id` = @iParentPageId);
  64. INSERT INTO `sys_std_widgets` (`page_id`, `module`, `type`, `url`, `click`, `icon`, `caption`, `cnt_notices`, `cnt_actions`) VALUES
  65. (@iPageId, 'bx_oauth', 'integrations', '{url_studio}module.php?name=bx_oauth&page=settings', '', 'bx_oauth@modules/boonex/oauth2/|std-icon.svg', '_bx_oauth', '', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:11:"get_actions";s:6:"params";a:0:{}s:5:"class";s:18:"TemplStudioModules";}');
  66. INSERT INTO `sys_std_pages_widgets` (`page_id`, `widget_id`, `order`) VALUES
  67. (@iParentPageId, LAST_INSERT_ID(), IF(ISNULL(@iParentPageOrder), 1, @iParentPageOrder + 1));