From a0f888e8bcb68d3186a3c8ab1a2681ca5ef02ba2 Mon Sep 17 00:00:00 2001 From: KubrickCode <126654223+KubrickCode@users.noreply.github.com> Date: Fri, 23 Jan 2026 12:50:33 +0000 Subject: [PATCH] docs: update schema documentation --- docs/schema/README.md | 4 +- docs/schema/public.analyses.md | 1 + docs/schema/public.spec_documents.md | 39 ++++++++++----- docs/schema/public.spec_domains.md | 1 + docs/schema/public.usage_events.md | 1 + docs/schema/public.user_specview_history.md | 1 + docs/schema/public.users.md | 33 +++++++++---- docs/schema/schema.json | 53 ++++++++++++++++----- 8 files changed, 98 insertions(+), 35 deletions(-) diff --git a/docs/schema/README.md b/docs/schema/README.md index 199a6ad..9df0f57 100644 --- a/docs/schema/README.md +++ b/docs/schema/README.md @@ -20,7 +20,7 @@ | [public.refresh_tokens](public.refresh_tokens.md) | 8 | | BASE TABLE | | [public.test_files](public.test_files.md) | 5 | | BASE TABLE | | [public.system_config](public.system_config.md) | 3 | | BASE TABLE | -| [public.spec_documents](public.spec_documents.md) | 9 | | BASE TABLE | +| [public.spec_documents](public.spec_documents.md) | 10 | | BASE TABLE | | [public.spec_domains](public.spec_domains.md) | 8 | | BASE TABLE | | [public.spec_features](public.spec_features.md) | 7 | | BASE TABLE | | [public.spec_behaviors](public.spec_behaviors.md) | 7 | | BASE TABLE | @@ -65,6 +65,7 @@ erDiagram "public.refresh_tokens" }o--o| "public.refresh_tokens" : "FOREIGN KEY (replaces) REFERENCES refresh_tokens(id) ON DELETE SET NULL" "public.test_files" }o--|| "public.analyses" : "FOREIGN KEY (analysis_id) REFERENCES analyses(id) ON DELETE CASCADE" "public.spec_documents" }o--|| "public.analyses" : "FOREIGN KEY (analysis_id) REFERENCES analyses(id) ON DELETE CASCADE" +"public.spec_documents" }o--|| "public.users" : "FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE" "public.spec_domains" }o--|| "public.spec_documents" : "FOREIGN KEY (document_id) REFERENCES spec_documents(id) ON DELETE CASCADE" "public.spec_features" }o--|| "public.spec_domains" : "FOREIGN KEY (domain_id) REFERENCES spec_domains(id) ON DELETE CASCADE" "public.spec_behaviors" }o--o| "public.test_cases" : "FOREIGN KEY (source_test_case_id) REFERENCES test_cases(id) ON DELETE SET NULL" @@ -254,6 +255,7 @@ erDiagram timestamp_with_time_zone created_at timestamp_with_time_zone updated_at integer version + uuid user_id FK } "public.spec_domains" { uuid id diff --git a/docs/schema/public.analyses.md b/docs/schema/public.analyses.md index 9798a97..331cbcf 100644 --- a/docs/schema/public.analyses.md +++ b/docs/schema/public.analyses.md @@ -86,6 +86,7 @@ erDiagram timestamp_with_time_zone created_at timestamp_with_time_zone updated_at integer version + uuid user_id FK } "public.usage_events" { uuid id diff --git a/docs/schema/public.spec_documents.md b/docs/schema/public.spec_documents.md index 4b1f8dc..213e185 100644 --- a/docs/schema/public.spec_documents.md +++ b/docs/schema/public.spec_documents.md @@ -15,24 +15,27 @@ | created_at | timestamp with time zone | now() | false | | | | | updated_at | timestamp with time zone | now() | false | | | | | version | integer | 1 | false | | | | +| user_id | uuid | | false | | [public.users](public.users.md) | | ## Constraints -| Name | Type | Definition | -| ----------------------------------------- | ----------- | ------------------------------------------------------------------- | -| fk_spec_documents_analysis | FOREIGN KEY | FOREIGN KEY (analysis_id) REFERENCES analyses(id) ON DELETE CASCADE | -| spec_documents_pkey | PRIMARY KEY | PRIMARY KEY (id) | -| uq_spec_documents_analysis_lang_version | UNIQUE | UNIQUE (analysis_id, language, version) | -| uq_spec_documents_hash_lang_model_version | UNIQUE | UNIQUE (content_hash, language, model_id, version) | +| Name | Type | Definition | +| ---------------------------------------------- | ----------- | ------------------------------------------------------------------- | +| fk_spec_documents_analysis | FOREIGN KEY | FOREIGN KEY (analysis_id) REFERENCES analyses(id) ON DELETE CASCADE | +| fk_spec_documents_user | FOREIGN KEY | FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE | +| spec_documents_pkey | PRIMARY KEY | PRIMARY KEY (id) | +| uq_spec_documents_user_analysis_lang_version | UNIQUE | UNIQUE (user_id, analysis_id, language, version) | +| uq_spec_documents_user_hash_lang_model_version | UNIQUE | UNIQUE (user_id, content_hash, language, model_id, version) | ## Indexes -| Name | Definition | -| ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -| spec_documents_pkey | CREATE UNIQUE INDEX spec_documents_pkey ON public.spec_documents USING btree (id) | -| idx_spec_documents_analysis | CREATE INDEX idx_spec_documents_analysis ON public.spec_documents USING btree (analysis_id) | -| uq_spec_documents_analysis_lang_version | CREATE UNIQUE INDEX uq_spec_documents_analysis_lang_version ON public.spec_documents USING btree (analysis_id, language, version) | -| uq_spec_documents_hash_lang_model_version | CREATE UNIQUE INDEX uq_spec_documents_hash_lang_model_version ON public.spec_documents USING btree (content_hash, language, model_id, version) | +| Name | Definition | +| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| spec_documents_pkey | CREATE UNIQUE INDEX spec_documents_pkey ON public.spec_documents USING btree (id) | +| idx_spec_documents_analysis | CREATE INDEX idx_spec_documents_analysis ON public.spec_documents USING btree (analysis_id) | +| uq_spec_documents_user_analysis_lang_version | CREATE UNIQUE INDEX uq_spec_documents_user_analysis_lang_version ON public.spec_documents USING btree (user_id, analysis_id, language, version) | +| uq_spec_documents_user_hash_lang_model_version | CREATE UNIQUE INDEX uq_spec_documents_user_hash_lang_model_version ON public.spec_documents USING btree (user_id, content_hash, language, model_id, version) | +| idx_spec_documents_user_created | CREATE INDEX idx_spec_documents_user_created ON public.spec_documents USING btree (user_id, created_at) | ## Relations @@ -43,6 +46,7 @@ erDiagram "public.user_specview_history" }o--|| "public.spec_documents" : "FOREIGN KEY (document_id) REFERENCES spec_documents(id) ON DELETE CASCADE" "public.usage_events" }o--o| "public.spec_documents" : "FOREIGN KEY (document_id) REFERENCES spec_documents(id) ON DELETE SET NULL" "public.spec_documents" }o--|| "public.analyses" : "FOREIGN KEY (analysis_id) REFERENCES analyses(id) ON DELETE CASCADE" +"public.spec_documents" }o--|| "public.users" : "FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE" "public.spec_documents" { uuid id @@ -54,6 +58,7 @@ erDiagram timestamp_with_time_zone created_at timestamp_with_time_zone updated_at integer version + uuid user_id FK } "public.spec_domains" { uuid id @@ -96,6 +101,16 @@ erDiagram timestamp_with_time_zone committed_at varchar_100_ parser_version } +"public.users" { + uuid id + varchar_255_ email + varchar_255_ username + text avatar_url + timestamp_with_time_zone last_login_at + timestamp_with_time_zone created_at + timestamp_with_time_zone updated_at + integer token_version +} ``` --- diff --git a/docs/schema/public.spec_domains.md b/docs/schema/public.spec_domains.md index a7d0e34..c3d94b3 100644 --- a/docs/schema/public.spec_domains.md +++ b/docs/schema/public.spec_domains.md @@ -66,6 +66,7 @@ erDiagram timestamp_with_time_zone created_at timestamp_with_time_zone updated_at integer version + uuid user_id FK } ``` diff --git a/docs/schema/public.usage_events.md b/docs/schema/public.usage_events.md index 9392dbf..904d476 100644 --- a/docs/schema/public.usage_events.md +++ b/docs/schema/public.usage_events.md @@ -86,6 +86,7 @@ erDiagram timestamp_with_time_zone created_at timestamp_with_time_zone updated_at integer version + uuid user_id FK } ``` diff --git a/docs/schema/public.user_specview_history.md b/docs/schema/public.user_specview_history.md index 0c0d81e..7cf6876 100644 --- a/docs/schema/public.user_specview_history.md +++ b/docs/schema/public.user_specview_history.md @@ -65,6 +65,7 @@ erDiagram timestamp_with_time_zone created_at timestamp_with_time_zone updated_at integer version + uuid user_id FK } ``` diff --git a/docs/schema/public.users.md b/docs/schema/public.users.md index 9100994..8442f5f 100644 --- a/docs/schema/public.users.md +++ b/docs/schema/public.users.md @@ -4,16 +4,16 @@ ## Columns -| Name | Type | Default | Nullable | Children | Parents | Comment | -| ------------- | ------------------------ | ----------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ------- | -| id | uuid | gen_random_uuid() | false | [public.oauth_accounts](public.oauth_accounts.md) [public.user_bookmarks](public.user_bookmarks.md) [public.user_analysis_history](public.user_analysis_history.md) [public.user_github_org_memberships](public.user_github_org_memberships.md) [public.user_github_repositories](public.user_github_repositories.md) [public.github_app_installations](public.github_app_installations.md) [public.refresh_tokens](public.refresh_tokens.md) [public.user_specview_history](public.user_specview_history.md) [public.usage_events](public.usage_events.md) [public.user_subscriptions](public.user_subscriptions.md) | | | -| email | varchar(255) | | true | | | | -| username | varchar(255) | | false | | | | -| avatar_url | text | | true | | | | -| last_login_at | timestamp with time zone | | true | | | | -| created_at | timestamp with time zone | now() | false | | | | -| updated_at | timestamp with time zone | now() | false | | | | -| token_version | integer | 1 | false | | | | +| Name | Type | Default | Nullable | Children | Parents | Comment | +| ------------- | ------------------------ | ----------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ------- | +| id | uuid | gen_random_uuid() | false | [public.oauth_accounts](public.oauth_accounts.md) [public.user_bookmarks](public.user_bookmarks.md) [public.user_analysis_history](public.user_analysis_history.md) [public.user_github_org_memberships](public.user_github_org_memberships.md) [public.user_github_repositories](public.user_github_repositories.md) [public.github_app_installations](public.github_app_installations.md) [public.refresh_tokens](public.refresh_tokens.md) [public.spec_documents](public.spec_documents.md) [public.user_specview_history](public.user_specview_history.md) [public.usage_events](public.usage_events.md) [public.user_subscriptions](public.user_subscriptions.md) | | | +| email | varchar(255) | | true | | | | +| username | varchar(255) | | false | | | | +| avatar_url | text | | true | | | | +| last_login_at | timestamp with time zone | | true | | | | +| created_at | timestamp with time zone | now() | false | | | | +| updated_at | timestamp with time zone | now() | false | | | | +| token_version | integer | 1 | false | | | | ## Constraints @@ -41,6 +41,7 @@ erDiagram "public.user_github_repositories" }o--|| "public.users" : "FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE" "public.github_app_installations" }o--o| "public.users" : "FOREIGN KEY (installer_user_id) REFERENCES users(id) ON DELETE SET NULL" "public.refresh_tokens" }o--|| "public.users" : "FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE" +"public.spec_documents" }o--|| "public.users" : "FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE" "public.user_specview_history" }o--|| "public.users" : "FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE" "public.usage_events" }o--|| "public.users" : "FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE" "public.user_subscriptions" }o--|| "public.users" : "FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE" @@ -131,6 +132,18 @@ erDiagram timestamp_with_time_zone revoked_at uuid replaces FK } +"public.spec_documents" { + uuid id + uuid analysis_id FK + bytea content_hash + varchar_10_ language + text executive_summary + varchar_100_ model_id + timestamp_with_time_zone created_at + timestamp_with_time_zone updated_at + integer version + uuid user_id FK +} "public.user_specview_history" { uuid id uuid user_id FK diff --git a/docs/schema/schema.json b/docs/schema/schema.json index 3a1ee03..6a704e3 100644 --- a/docs/schema/schema.json +++ b/docs/schema/schema.json @@ -1655,6 +1655,11 @@ "type": "integer", "nullable": false, "default": "1" + }, + { + "name": "user_id", + "type": "uuid", + "nullable": false } ], "indexes": [ @@ -1671,16 +1676,22 @@ "columns": ["analysis_id"] }, { - "name": "uq_spec_documents_analysis_lang_version", - "def": "CREATE UNIQUE INDEX uq_spec_documents_analysis_lang_version ON public.spec_documents USING btree (analysis_id, language, version)", + "name": "uq_spec_documents_user_analysis_lang_version", + "def": "CREATE UNIQUE INDEX uq_spec_documents_user_analysis_lang_version ON public.spec_documents USING btree (user_id, analysis_id, language, version)", "table": "public.spec_documents", - "columns": ["analysis_id", "language", "version"] + "columns": ["user_id", "analysis_id", "language", "version"] }, { - "name": "uq_spec_documents_hash_lang_model_version", - "def": "CREATE UNIQUE INDEX uq_spec_documents_hash_lang_model_version ON public.spec_documents USING btree (content_hash, language, model_id, version)", + "name": "uq_spec_documents_user_hash_lang_model_version", + "def": "CREATE UNIQUE INDEX uq_spec_documents_user_hash_lang_model_version ON public.spec_documents USING btree (user_id, content_hash, language, model_id, version)", "table": "public.spec_documents", - "columns": ["content_hash", "language", "model_id", "version"] + "columns": ["user_id", "content_hash", "language", "model_id", "version"] + }, + { + "name": "idx_spec_documents_user_created", + "def": "CREATE INDEX idx_spec_documents_user_created ON public.spec_documents USING btree (user_id, created_at)", + "table": "public.spec_documents", + "columns": ["user_id", "created_at"] } ], "constraints": [ @@ -1693,6 +1704,15 @@ "columns": ["analysis_id"], "referenced_columns": ["id"] }, + { + "name": "fk_spec_documents_user", + "type": "FOREIGN KEY", + "def": "FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE", + "table": "public.spec_documents", + "referenced_table": "users", + "columns": ["user_id"], + "referenced_columns": ["id"] + }, { "name": "spec_documents_pkey", "type": "PRIMARY KEY", @@ -1702,20 +1722,20 @@ "columns": ["id"] }, { - "name": "uq_spec_documents_analysis_lang_version", + "name": "uq_spec_documents_user_analysis_lang_version", "type": "UNIQUE", - "def": "UNIQUE (analysis_id, language, version)", + "def": "UNIQUE (user_id, analysis_id, language, version)", "table": "public.spec_documents", "referenced_table": "", - "columns": ["analysis_id", "language", "version"] + "columns": ["user_id", "analysis_id", "language", "version"] }, { - "name": "uq_spec_documents_hash_lang_model_version", + "name": "uq_spec_documents_user_hash_lang_model_version", "type": "UNIQUE", - "def": "UNIQUE (content_hash, language, model_id, version)", + "def": "UNIQUE (user_id, content_hash, language, model_id, version)", "table": "public.spec_documents", "referenced_table": "", - "columns": ["content_hash", "language", "model_id", "version"] + "columns": ["user_id", "content_hash", "language", "model_id", "version"] } ] }, @@ -2538,6 +2558,15 @@ "parent_cardinality": "exactly_one", "def": "FOREIGN KEY (analysis_id) REFERENCES analyses(id) ON DELETE CASCADE" }, + { + "table": "public.spec_documents", + "columns": ["user_id"], + "cardinality": "zero_or_more", + "parent_table": "public.users", + "parent_columns": ["id"], + "parent_cardinality": "exactly_one", + "def": "FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE" + }, { "table": "public.spec_domains", "columns": ["document_id"],