@@ -727,114 +727,296 @@ journey
727727
728728## Database Schema
729729
730+ > 17 tables across 38 migrations. All tables have Row-Level Security enabled.
731+
730732``` mermaid
731733erDiagram
732- PROFILES ||--o{ REPOS : owns
733- PROFILES ||--o{ SPECS : creates
734- PROFILES ||--o{ INCIDENTS : reports
735- PROFILES ||--o{ CHAT_THREADS : has
736-
737- REPOS ||--o{ SPECS : contains
738- REPOS ||--o{ CI_RUNS : has
739- REPOS ||--o{ RELEASE_TRACES : tracks
740-
741- SPECS ||--o{ RELEASE_TRACES : generates
742- SPECS ||--o| INCIDENTS : linked_to
743-
744- RELEASE_TRACES ||--o{ TRACE_EVENTS : has
745- RELEASE_TRACES ||--o{ APPROVAL_EVENTS : requires
746-
747- INCIDENTS ||--o{ RELEASE_TRACES : triggers_hotfix
748-
734+ %% ── Core ───────────────────────────────────────────────────────────────
735+ PROFILES ||--o{ REPOS : "owns"
736+ PROFILES ||--o{ SPECS : "creates"
737+ PROFILES ||--o{ INCIDENTS : "reports"
738+ PROFILES ||--o{ RELEASE_TRACES : "owns"
739+ PROFILES ||--o{ CI_RUNS : "owns"
740+ PROFILES ||--o{ APPROVAL_EVENTS : "makes"
741+ PROFILES ||--o{ NOTIFICATIONS : "receives"
742+ PROFILES ||--o{ CHAT_THREADS : "has"
743+ PROFILES ||--o{ CHAT_MESSAGES : "writes"
744+ PROFILES ||--o{ AI_MEMORY_NOTES : "stores"
745+ PROFILES ||--o{ ROLLBACK_HISTORY : "initiates"
746+ PROFILES ||--o| TELEGRAM_USERS : "links"
747+
748+ REPOS ||--o{ SPECS : "contains"
749+ REPOS ||--o{ CI_RUNS : "has"
750+ REPOS ||--o{ RELEASE_TRACES : "tracks"
751+
752+ %% ── Release ────────────────────────────────────────────────────────────
753+ SPECS ||--o{ RELEASE_TRACES : "generates"
754+ SPECS |o--o{ ROLLBACK_HISTORY : "referenced by"
755+
756+ RELEASE_TRACES ||--o{ TRACE_EVENTS : "has"
757+ RELEASE_TRACES ||--o{ APPROVAL_EVENTS : "requires"
758+ RELEASE_TRACES |o--o{ ROLLBACK_HISTORY : "rolled back via"
759+ RELEASE_TRACES }o--o| INCIDENTS : "hotfix for"
760+
761+ %% ── Chat ───────────────────────────────────────────────────────────────
762+ CHAT_THREADS ||--o{ CHAT_MESSAGES : "contains"
763+
764+ %% ── Telegram ───────────────────────────────────────────────────────────
765+ TELEGRAM_USERS ||--o{ TELEGRAM_NOTIFICATION_DELIVERIES : "receives"
766+ NOTIFICATIONS ||--o{ TELEGRAM_NOTIFICATION_DELIVERIES : "delivered via"
767+
768+ %% ── Table definitions ──────────────────────────────────────────────────
749769 PROFILES {
750770 uuid id PK
751771 text github_login
752772 text github_access_token
753773 text avatar_url
754- timestamp created_at
774+ text active_repo_full_name
775+ timestamptz created_at
755776 }
756777
757778 REPOS {
758779 uuid id PK
759780 uuid user_id FK
760- int github_repo_id
781+ bigint github_repo_id
761782 text full_name
762783 text default_branch
763784 text setup_status
785+ int setup_pr_number
786+ text setup_pr_url
787+ text setup_branch
764788 text shipbrain_api_key_hash
789+ text shipbrain_api_key_last4
765790 jsonb setup_metadata
791+ text current_version
792+ text current_version_sha
793+ timestamptz current_version_deployed_at
794+ text current_version_type
795+ boolean telegram_notifications_enabled
796+ timestamptz connected_at
766797 }
767798
768799 SPECS {
769800 uuid id PK
770801 uuid user_id FK
802+ uuid repo_id FK
771803 text repo_full_name
772- text title
773- text original_content
774- jsonb tasks
775- text status
804+ text raw_spec
805+ jsonb decomposed_tasks
806+ jsonb scaffold_code
776807 int pr_number
777808 text pr_url
778- text release_tag
809+ text branch_name
810+ text base_branch
811+ text status
779812 text release_status
813+ text release_tag
814+ text preview_status
815+ text preview_url
816+ text production_url
817+ timestamptz created_at
818+ timestamptz updated_at
819+ }
820+
821+ CI_RUNS {
822+ uuid id PK
823+ uuid user_id FK
824+ uuid repo_id FK
825+ text repo_full_name
826+ bigint github_run_id
827+ text workflow_name
828+ text title
829+ text branch
830+ text status
831+ text conclusion
832+ text html_url
833+ text ai_explanation
834+ text ai_fix_suggestion
835+ jsonb metadata
836+ timestamptz created_at
837+ timestamptz updated_at
780838 }
781839
782840 RELEASE_TRACES {
783841 uuid id PK
784842 uuid user_id FK
785843 uuid spec_id FK
844+ uuid incident_id FK
786845 text repo_full_name
787- text trace_type
846+ text type
847+ text title
848+ text description
788849 text status
789- text pr_number
790- text release_tag
850+ text current_phase
851+ jsonb pending_action
852+ text source_branch
853+ text target_branch
854+ int draft_pr_number
855+ text draft_pr_url
856+ int release_pr_number
857+ text release_pr_url
791858 jsonb preview_deployment
792859 jsonb production_deployment
793- text pending_action
794- timestamp created_at
860+ int reverse_sync_pr_number
861+ text reverse_sync_pr_url
862+ text reverse_sync_status
863+ boolean is_rollback
864+ text rollback_source_tag
865+ text rollback_target_tag
866+ timestamptz created_at
867+ timestamptz updated_at
868+ timestamptz completed_at
795869 }
796870
797871 TRACE_EVENTS {
798872 uuid id PK
799873 uuid trace_id FK
800874 text event_type
801875 text actor
802- jsonb payload
803- timestamp created_at
876+ text actor_type
877+ jsonb details
878+ text source
879+ timestamptz created_at
880+ }
881+
882+ APPROVAL_EVENTS {
883+ uuid id PK
884+ text entity_type
885+ text entity_id
886+ text action
887+ uuid actor_id FK
888+ text note
889+ jsonb metadata
890+ timestamptz created_at
804891 }
805892
806893 INCIDENTS {
807894 uuid id PK
808895 uuid user_id FK
809896 text repo_full_name
810- text severity
897+ text alert_source
811898 text status
899+ text severity
900+ text service
901+ text environment
812902 text title
813- text description
814- jsonb ai_analysis
815- jsonb postmortem
816- uuid hotfix_trace_id FK
903+ text raw_logs
904+ text root_cause
905+ text ai_fix_proposal
906+ text postmortem_draft
907+ text release_version
908+ int hotfix_pr_number
909+ text hotfix_pr_url
910+ text external_id
911+ timestamptz created_at
912+ timestamptz updated_at
817913 }
818914
819- CI_RUNS {
915+ ROLLBACK_HISTORY {
820916 uuid id PK
821917 uuid user_id FK
918+ uuid trace_id FK
919+ uuid spec_id FK
822920 text repo_full_name
823- bigint run_id
921+ text source_release_tag
922+ text target_release_tag
923+ text target_release_sha
824924 text status
825- text conclusion
826- text head_branch
827- jsonb ai_analysis
925+ text initiated_by
926+ text workflow_url
927+ text error_message
928+ jsonb metadata
929+ timestamptz initiated_at
930+ timestamptz completed_at
828931 }
829932
830- APPROVAL_EVENTS {
933+ NOTIFICATIONS {
831934 uuid id PK
832- uuid trace_id FK
833935 uuid user_id FK
834- text action
835- text decision
836- text notes
837- timestamp created_at
936+ text repo_full_name
937+ text type
938+ text title
939+ text body
940+ text href
941+ text severity
942+ jsonb metadata
943+ text dedupe_key
944+ timestamptz read_at
945+ timestamptz created_at
946+ }
947+
948+ CHAT_THREADS {
949+ uuid id PK
950+ uuid user_id FK
951+ text repo_full_name
952+ text channel
953+ text external_thread_key
954+ text title
955+ timestamptz created_at
956+ timestamptz updated_at
957+ }
958+
959+ CHAT_MESSAGES {
960+ uuid id PK
961+ uuid thread_id FK
962+ uuid user_id FK
963+ text role
964+ text content
965+ jsonb metadata
966+ timestamptz created_at
967+ }
968+
969+ AI_MEMORY_NOTES {
970+ uuid id PK
971+ uuid user_id FK
972+ text repo_full_name
973+ text key
974+ text value
975+ text category
976+ timestamptz created_at
977+ timestamptz updated_at
978+ }
979+
980+ SPEC_PR_RECIPES {
981+ text id PK
982+ text label
983+ text prefix
984+ text base_branch
985+ text source_branch
986+ text ticket
987+ boolean is_sample
988+ boolean active
989+ int sort_order
990+ timestamptz created_at
991+ }
992+
993+ TELEGRAM_USERS {
994+ uuid id PK
995+ uuid user_id FK
996+ bigint telegram_chat_id
997+ text telegram_username
998+ boolean verified
999+ text verification_code
1000+ timestamptz created_at
1001+ }
1002+
1003+ TELEGRAM_NOTIFICATION_DELIVERIES {
1004+ uuid id PK
1005+ uuid notification_id FK
1006+ uuid telegram_user_id FK
1007+ text status
1008+ int attempts
1009+ text last_error
1010+ timestamptz sent_at
1011+ timestamptz created_at
1012+ }
1013+
1014+ TELEGRAM_WEBHOOK_UPDATES {
1015+ bigint update_id PK
1016+ bigint telegram_chat_id
1017+ text status
1018+ text error_fingerprint
1019+ timestamptz created_at
8381020 }
8391021```
8401022
0 commit comments