murkup.txt 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. users {
  2. id uuid pk
  3. username text unique
  4. password_hash text
  5. role user_role
  6. is_active boolean
  7. created_at timestamptz
  8. updated_at timestamptz
  9. @index idx_users_role (role)
  10. @index idx_users_active (is_active)
  11. }
  12. agents {
  13. id uuid pk
  14. hostname text unique
  15. token_hash text
  16. cert_fingerprint text
  17. os_info jsonb
  18. status enum
  19. is_active boolean
  20. last_seen timestamptz
  21. registered_at timestamptz
  22. updated_at timestamptz
  23. @index idx_agents_status (status)
  24. @index idx_agents_last_seen (last_seen)
  25. @index idx_agents_active (is_active)
  26. @index idx_agents_os_info_gin (os_info)
  27. }
  28. command_types {
  29. id smallserial pk
  30. name text unique
  31. }
  32. commands {
  33. id uuid pk
  34. agent_id uuid > agents.id
  35. issued_by uuid > users.id
  36. command_type_id smallint > command_types.id
  37. command text
  38. status enum
  39. output text
  40. exit_code integer
  41. created_at timestamptz
  42. completed_at timestamptz
  43. updated_at timestamptz
  44. @index idx_commands_agent (agent_id)
  45. @index idx_commands_issued_by (issued_by)
  46. @index idx_commands_status (status)
  47. @index idx_commands_created_at (created_at)
  48. }
  49. file_transfers {
  50. id uuid pk
  51. agent_id uuid > agents.id
  52. initiated_by uuid > users.id
  53. command_id uuid > commands.id
  54. direction transfer_direction
  55. filename text
  56. sha256 char(64)
  57. size_bytes bigint
  58. status enum
  59. created_at timestamptz
  60. updated_at timestamptz
  61. @index idx_file_transfers_agent (agent_id)
  62. @index idx_file_transfers_status (status)
  63. @index idx_file_transfers_sha256 (sha256)
  64. @index idx_file_transfers_created (created_at)
  65. }
  66. audit_logs {
  67. id uuid pk
  68. actor_id uuid
  69. actor_type enum
  70. action text
  71. target text
  72. details jsonb
  73. ip_address inet
  74. created_at timestamptz
  75. @index idx_audit_actor (actor_id)
  76. @index idx_audit_action (action)
  77. @index idx_audit_created (created_at)
  78. @index idx_audit_details_gin (details)
  79. }
  80. agent_heartbeats {
  81. id bigserial pk
  82. agent_id uuid > agents.id
  83. received_at timestamptz
  84. metadata jsonb
  85. @index idx_heartbeats_agent (agent_id)
  86. @index idx_heartbeats_received (received_at)
  87. }
  88. user_sessions {
  89. id uuid pk
  90. user_id uuid > users.id
  91. refresh_token_hash text
  92. user_agent text
  93. ip_address inet
  94. expires_at timestamptz
  95. created_at timestamptz
  96. @index idx_sessions_user (user_id)
  97. @index idx_sessions_expires (expires_at)
  98. }
  99. agent_groups {
  100. id uuid pk
  101. name text unique
  102. description text
  103. created_at timestamptz
  104. }
  105. agent_group_members {
  106. agent_id uuid pk > agents.id
  107. group_id uuid pk > agent_groups.id
  108. }