LATEST__SCHEMA.sql 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. -- migration_history
  2. CREATE TABLE `migration_history` (
  3. `version` VARCHAR(256) NOT NULL PRIMARY KEY,
  4. `created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
  5. );
  6. -- system_setting
  7. CREATE TABLE `system_setting` (
  8. `name` VARCHAR(256) NOT NULL PRIMARY KEY,
  9. `value` LONGTEXT NOT NULL,
  10. `description` TEXT NOT NULL
  11. );
  12. -- user
  13. CREATE TABLE `user` (
  14. `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  15. `created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  16. `updated_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  17. `row_status` VARCHAR(256) NOT NULL DEFAULT 'NORMAL',
  18. `username` VARCHAR(256) NOT NULL UNIQUE,
  19. `role` VARCHAR(256) NOT NULL DEFAULT 'USER',
  20. `email` VARCHAR(256) NOT NULL DEFAULT '',
  21. `nickname` VARCHAR(256) NOT NULL DEFAULT '',
  22. `password_hash` VARCHAR(256) NOT NULL,
  23. `avatar_url` LONGTEXT NOT NULL
  24. );
  25. -- user_setting
  26. CREATE TABLE `user_setting` (
  27. `user_id` INT NOT NULL,
  28. `key` VARCHAR(256) NOT NULL,
  29. `value` LONGTEXT NOT NULL,
  30. UNIQUE(`user_id`,`key`)
  31. );
  32. -- memo
  33. CREATE TABLE `memo` (
  34. `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  35. `resource_name` VARCHAR(256) NOT NULL UNIQUE,
  36. `creator_id` INT NOT NULL,
  37. `created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  38. `updated_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  39. `row_status` VARCHAR(256) NOT NULL DEFAULT 'NORMAL',
  40. `content` TEXT NOT NULL,
  41. `visibility` VARCHAR(256) NOT NULL DEFAULT 'PRIVATE'
  42. );
  43. -- memo_organizer
  44. CREATE TABLE `memo_organizer` (
  45. `memo_id` INT NOT NULL,
  46. `user_id` INT NOT NULL,
  47. `pinned` INT NOT NULL DEFAULT '0',
  48. UNIQUE(`memo_id`,`user_id`)
  49. );
  50. -- memo_relation
  51. CREATE TABLE `memo_relation` (
  52. `memo_id` INT NOT NULL,
  53. `related_memo_id` INT NOT NULL,
  54. `type` VARCHAR(256) NOT NULL,
  55. UNIQUE(`memo_id`,`related_memo_id`,`type`)
  56. );
  57. -- resource
  58. CREATE TABLE `resource` (
  59. `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  60. `resource_name` VARCHAR(256) NOT NULL UNIQUE,
  61. `creator_id` INT NOT NULL,
  62. `created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  63. `updated_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  64. `filename` TEXT NOT NULL,
  65. `blob` MEDIUMBLOB,
  66. `external_link` TEXT NOT NULL,
  67. `type` VARCHAR(256) NOT NULL DEFAULT '',
  68. `size` INT NOT NULL DEFAULT '0',
  69. `internal_path` VARCHAR(256) NOT NULL DEFAULT '',
  70. `memo_id` INT DEFAULT NULL
  71. );
  72. -- tag
  73. CREATE TABLE `tag` (
  74. `name` VARCHAR(256) NOT NULL,
  75. `creator_id` INT NOT NULL,
  76. UNIQUE(`name`,`creator_id`)
  77. );
  78. -- activity
  79. CREATE TABLE `activity` (
  80. `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  81. `creator_id` INT NOT NULL,
  82. `created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  83. `type` VARCHAR(256) NOT NULL DEFAULT '',
  84. `level` VARCHAR(256) NOT NULL DEFAULT 'INFO',
  85. `payload` TEXT NOT NULL
  86. );
  87. -- storage
  88. CREATE TABLE `storage` (
  89. `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  90. `name` VARCHAR(256) NOT NULL,
  91. `type` VARCHAR(256) NOT NULL,
  92. `config` TEXT NOT NULL
  93. );
  94. -- idp
  95. CREATE TABLE `idp` (
  96. `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  97. `name` TEXT NOT NULL,
  98. `type` TEXT NOT NULL,
  99. `identifier_filter` VARCHAR(256) NOT NULL DEFAULT '',
  100. `config` TEXT NOT NULL
  101. );
  102. -- inbox
  103. CREATE TABLE `inbox` (
  104. `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  105. `created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  106. `sender_id` INT NOT NULL,
  107. `receiver_id` INT NOT NULL,
  108. `status` TEXT NOT NULL,
  109. `message` TEXT NOT NULL
  110. );
  111. -- webhook
  112. CREATE TABLE `webhook` (
  113. `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  114. `created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  115. `updated_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  116. `row_status` VARCHAR(256) NOT NULL DEFAULT 'NORMAL',
  117. `creator_id` INT NOT NULL,
  118. `name` TEXT NOT NULL,
  119. `url` TEXT NOT NULL
  120. );