dbschema.json 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. {
  2. "db_name": "ZeroMe",
  3. "db_file": "merged-ZeroMe/ZeroMe.db",
  4. "version": 3,
  5. "maps": {
  6. ".+/data/userdb/.+/content.json": {
  7. "to_json_table": [ "cert_auth_type", "cert_user_id" ],
  8. "to_table": ["user"]
  9. },
  10. ".+/data/userdb/users.*json": {
  11. "to_table": ["user"]
  12. },
  13. ".+/data/users/.+/content.json": {
  14. "to_json_table": [ "cert_auth_type", "cert_user_id" ],
  15. "file_name": "data.json"
  16. },
  17. ".+/data/users/.+/data.json": {
  18. "to_table": [
  19. "post",
  20. "comment",
  21. "follow",
  22. {"node": "post_like", "table": "post_like", "key_col": "post_uri", "val_col": "date_added"}
  23. ],
  24. "to_json_table": [ "hub", "user_name", "avatar", "intro" ]
  25. }
  26. },
  27. "tables": {
  28. "json": {
  29. "cols": [
  30. ["json_id", "INTEGER PRIMARY KEY AUTOINCREMENT"],
  31. ["site", "TEXT"],
  32. ["directory", "TEXT"],
  33. ["file_name", "TEXT"],
  34. ["cert_auth_type", "TEXT"],
  35. ["cert_user_id", "TEXT"],
  36. ["hub", "TEXT"],
  37. ["user_name", "TEXT"],
  38. ["intro", "TEXT"],
  39. ["avatar", "TEXT"]
  40. ],
  41. "indexes": ["CREATE UNIQUE INDEX path ON json(directory, site, file_name)"],
  42. "schema_changed": 4
  43. },
  44. "post": {
  45. "cols": [
  46. ["post_id", "INTEGER"],
  47. ["body", "TEXT"],
  48. ["meta", "TEXT"],
  49. ["date_added", "INTEGER"],
  50. ["json_id", "INTEGER REFERENCES json (json_id)"]
  51. ],
  52. "indexes": ["CREATE UNIQUE INDEX post_key ON post(json_id, post_id)", "CREATE INDEX post_id ON post(post_id)", "CREATE INDEX added ON post(date_added)"],
  53. "schema_changed": 4
  54. },
  55. "post_like": {
  56. "cols": [
  57. ["post_uri", "TEXT"],
  58. ["date_added", "INTEGER"],
  59. ["json_id", "INTEGER REFERENCES json (json_id)"]
  60. ],
  61. "indexes": ["CREATE UNIQUE INDEX post_like_key ON post_like(json_id, date_added)", "CREATE INDEX post_uri ON post_like(post_uri)"],
  62. "schema_changed": 1
  63. },
  64. "comment": {
  65. "cols": [
  66. ["comment_id", "INTEGER"],
  67. ["post_uri", "TEXT"],
  68. ["body", "TEXT"],
  69. ["date_added", "INTEGER"],
  70. ["json_id", "INTEGER REFERENCES json (json_id)"]
  71. ],
  72. "indexes": ["CREATE UNIQUE INDEX comment_key ON comment(json_id, comment_id)", "CREATE INDEX comment_post_uri ON comment(post_uri)", "CREATE INDEX comment_date_added ON comment(date_added)"],
  73. "schema_changed": 2
  74. },
  75. "follow": {
  76. "cols": [
  77. ["follow_id", "INTEGER"],
  78. ["user_name", "TEXT"],
  79. ["auth_address", "TEXT"],
  80. ["hub", "TEXT"],
  81. ["date_added", "INTEGER"],
  82. ["json_id", "INTEGER REFERENCES json (json_id)"]
  83. ],
  84. "indexes": ["CREATE UNIQUE INDEX follow_key ON follow(json_id, follow_id)", "CREATE INDEX follow_date_added ON follow(date_added)"],
  85. "schema_changed": 2
  86. },
  87. "user": {
  88. "cols": [
  89. ["auth_address", "TEXT"],
  90. ["cert_user_id", "TEXT"],
  91. ["hub", "TEXT"],
  92. ["user_name", "TEXT"],
  93. ["avatar", "TEXT"],
  94. ["intro", "TEXT"],
  95. ["date_added", "INTEGER"],
  96. ["json_id", "INTEGER REFERENCES json (json_id)"]
  97. ],
  98. "indexes": ["CREATE INDEX json_id ON user(json_id)", "CREATE INDEX date_added ON user(date_added)"],
  99. "schema_changed": 3
  100. }
  101. },
  102. "feeds": {
  103. "Posts": "SELECT 'post' AS type, post.date_added AS date_added, 'In ' || json.user_name || \"'s post\" AS title, post.body AS body, '?Post/' || json.site || '/' || REPLACE(json.directory, 'data/users/', '') || '/' || post_id AS url FROM post LEFT JOIN json USING (json_id)",
  104. "Comments": "SELECT 'comment' AS type, comment.date_added AS date_added, 'a post' AS title, '@' || user_name || ': ' || comment.body AS body, '?Post/' || json.site || '/' || REPLACE(post_uri, '_', '/') AS url FROM comment LEFT JOIN json USING (json_id)"
  105. }
  106. }