schema.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import { appSchema, tableSchema } from '@nozbe/watermelondb';
  2. export default appSchema({
  3. version: 1,
  4. tables: [
  5. tableSchema({
  6. name: 'chats',
  7. columns: [
  8. { name: 'chat_uid', type: 'number', isOptional: true, isIndexed: true },
  9. { name: 'group_chat_token', type: 'string', isOptional: true, isIndexed: true },
  10. { name: 'name', type: 'string' },
  11. { name: 'avatar', type: 'string', isOptional: true },
  12. { name: 'avatar_local', type: 'string', isOptional: true },
  13. { name: 'avatar_etag', type: 'string', isOptional: true },
  14. { name: 'avatar_checked_at', type: 'number', isOptional: true },
  15. { name: 'short', type: 'string' },
  16. { name: 'sent_by', type: 'number' },
  17. { name: 'updated', type: 'number', isIndexed: true },
  18. { name: 'status', type: 'number' },
  19. { name: 'unread_count', type: 'number' },
  20. { name: 'last_message_id', type: 'number' },
  21. { name: 'pin', type: 'number' },
  22. { name: 'pin_order', type: 'number' },
  23. { name: 'archive', type: 'number' },
  24. { name: 'archive_order', type: 'number' },
  25. { name: 'attachement_name', type: 'string' },
  26. { name: 'encrypted', type: 'number' },
  27. { name: 'muted', type: 'number' },
  28. { name: 'user_type', type: 'string', isOptional: true },
  29. { name: 'group_avatar', type: 'string', isOptional: true },
  30. { name: 'can_send_messages', type: 'number', isOptional: true },
  31. { name: 'is_admin', type: 'number', isOptional: true },
  32. { name: 'announcement', type: 'number', isOptional: true },
  33. { name: 'is_dirty', type: 'boolean', isOptional: true },
  34. { name: 'dirty_actions', type: 'string', isOptional: true },
  35. { name: 'removed', type: 'boolean', isOptional: true }
  36. ]
  37. }),
  38. tableSchema({
  39. name: 'messages',
  40. columns: [
  41. { name: 'composite_id', type: 'string', isIndexed: true },
  42. { name: 'message_id', type: 'string' },
  43. { name: 'chat_uid', type: 'number', isOptional: true, isIndexed: true },
  44. { name: 'sender_id', type: 'number' },
  45. { name: 'recipient_id', type: 'number' },
  46. { name: 'text', type: 'string', isOptional: true },
  47. { name: 'timestamp', type: 'number', isIndexed: true },
  48. { name: 'received_at', type: 'number', isOptional: true },
  49. { name: 'read_at', type: 'number', isOptional: true },
  50. { name: 'status', type: 'string' },
  51. { name: 'deleted', type: 'boolean', isOptional: true },
  52. { name: 'reactions', type: 'string', isOptional: true },
  53. { name: 'edits', type: 'string', isOptional: true },
  54. { name: 'attachments', type: 'string', isOptional: true },
  55. { name: 'reply_to', type: 'number', isOptional: true },
  56. { name: 'encrypted', type: 'number', isOptional: true },
  57. { name: 'sender_name', type: 'string', isOptional: true },
  58. { name: 'sender_avatar', type: 'string', isOptional: true },
  59. { name: 'is_dirty', type: 'boolean', isOptional: true },
  60. { name: 'dirty_actions', type: 'string', isOptional: true }
  61. ]
  62. }),
  63. tableSchema({
  64. name: 'blocked_users',
  65. columns: [
  66. { name: 'user_id', type: 'number', isIndexed: true },
  67. { name: 'first_name', type: 'string' },
  68. { name: 'last_name', type: 'string' },
  69. { name: 'avatar', type: 'string', isOptional: true },
  70. { name: 'removed', type: 'boolean', isOptional: true },
  71. { name: 'is_dirty', type: 'boolean', isOptional: true },
  72. { name: 'dirty_actions', type: 'string', isOptional: true }
  73. ]
  74. })
  75. ]
  76. });