refactor(store,tools): migrate IDs from UUID to bigserial int64
Some checks failed
CI / build-and-test (push) Failing after -31m12s

All internal entity lookups now use bigserial primary keys (int64) while
GUIDs are retained for external/public identification. Updated store
functions (TouchProject, UpdateThoughtMetadata, AddThoughtAttachment) to
query by id instead of guid, added GetThoughtByID, changed semanticSearch
and all tool helpers to use *int64 project IDs, and updated retry/backfill
workers to use int64 thought IDs throughout.
This commit is contained in:
2026-05-03 11:43:34 +02:00
parent 9e6d05e055
commit 91239bcf4b
58 changed files with 1208 additions and 2774 deletions

View File

@@ -5,7 +5,7 @@ Table thoughts {
metadata jsonb [default: `'{}'::jsonb`]
created_at timestamptz [default: `now()`]
updated_at timestamptz [default: `now()`]
project_id uuid [ref: > projects.guid]
project_id bigint [ref: > projects.id]
archived_at timestamptz
}
@@ -19,7 +19,7 @@ Table projects {
}
Table thought_links {
id serial [pk]
id bigserial [pk]
from_id bigint [not null, ref: > thoughts.id]
to_id bigint [not null, ref: > thoughts.id]
relation text [not null]
@@ -35,7 +35,7 @@ Table thought_links {
Table embeddings {
id bigserial [pk]
guid uuid [unique, not null, default: `gen_random_uuid()`]
thought_id uuid [not null, ref: > thoughts.guid]
thought_id bigint [not null, ref: > thoughts.id]
model text [not null]
dim int [not null]
embedding vector [not null]

View File

@@ -1,8 +1,8 @@
Table stored_files {
id bigserial [pk]
guid uuid [unique, not null, default: `gen_random_uuid()`]
thought_id uuid [ref: > thoughts.guid]
project_id uuid [ref: > projects.guid]
thought_id bigint [ref: > thoughts.id]
project_id bigint [ref: > projects.id]
name text [not null]
media_type text [not null]
kind text [not null, default: 'file']
@@ -21,5 +21,5 @@ Table stored_files {
}
// Cross-file refs (for relspecgo merge)
Ref: stored_files.thought_id > thoughts.guid [delete: set null]
Ref: stored_files.project_id > projects.guid [delete: set null]
Ref: stored_files.thought_id > thoughts.id [delete: set null]
Ref: stored_files.project_id > projects.id [delete: set null]

View File

@@ -1,10 +1,11 @@
Table chat_histories {
id uuid [pk, default: `gen_random_uuid()`]
id bigserial [pk]
guid uuid [unique, not null, default: `gen_random_uuid()`]
session_id text [not null]
title text
channel text
agent_id text
project_id uuid [ref: > projects.guid]
project_id bigint [ref: > projects.id]
messages jsonb [not null, default: `'[]'`]
summary text
metadata jsonb [not null, default: `'{}'`]
@@ -29,10 +30,11 @@ Table tool_annotations {
}
// Cross-file refs (for relspecgo merge)
Ref: chat_histories.project_id > projects.guid [delete: set null]
Ref: chat_histories.project_id > projects.id [delete: set null]
Table learnings {
id uuid [pk, default: `gen_random_uuid()`]
id bigserial [pk]
guid uuid [unique, not null, default: `gen_random_uuid()`]
summary text [not null]
details text [not null, default: '']
category text [not null, default: 'insight']
@@ -43,13 +45,13 @@ Table learnings {
action_required boolean [not null, default: false]
source_type text
source_ref text
project_id uuid [ref: > projects.guid]
related_thought_id uuid [ref: > thoughts.guid]
related_skill_id uuid [ref: > agent_skills.id]
project_id bigint [ref: > projects.id]
related_thought_id bigint [ref: > thoughts.id]
related_skill_id bigint [ref: > agent_skills.id]
reviewed_by text
reviewed_at timestamptz
duplicate_of_learning_id uuid [ref: > learnings.id]
supersedes_learning_id uuid [ref: > learnings.id]
duplicate_of_learning_id bigint [ref: > learnings.id]
supersedes_learning_id bigint [ref: > learnings.id]
tags "text[]" [not null, default: `'{}'`]
created_at timestamptz [not null, default: `now()`]
updated_at timestamptz [not null, default: `now()`]
@@ -68,8 +70,8 @@ Table learnings {
}
// Cross-file refs (for relspecgo merge)
Ref: learnings.project_id > projects.guid [delete: set null]
Ref: learnings.related_thought_id > thoughts.guid [delete: set null]
Ref: learnings.project_id > projects.id [delete: set null]
Ref: learnings.related_thought_id > thoughts.id [delete: set null]
Ref: learnings.related_skill_id > agent_skills.id [delete: set null]
Ref: learnings.duplicate_of_learning_id > learnings.id [delete: set null]
Ref: learnings.supersedes_learning_id > learnings.id [delete: set null]

View File

@@ -1,16 +1,17 @@
Table plans {
id uuid [pk, default: `gen_random_uuid()`]
id bigserial [pk]
guid uuid [unique, not null, default: `gen_random_uuid()`]
title text [not null]
description text [not null, default: '']
status text [not null, default: 'draft'] // draft, active, blocked, completed, cancelled, superseded
priority text [not null, default: 'medium'] // low, medium, high, critical
project_id uuid [ref: > projects.guid]
project_id bigint [ref: > projects.id]
owner text
due_date timestamptz
completed_at timestamptz
reviewed_by text
last_reviewed_at timestamptz
supersedes_plan_id uuid [ref: > plans.id]
supersedes_plan_id bigint [ref: > plans.id]
tags "text[]" [not null, default: `'{}'`]
created_at timestamptz [not null, default: `now()`]
updated_at timestamptz [not null, default: `now()`]
@@ -29,9 +30,9 @@ Table plans {
// Directional: plan_id cannot proceed until depends_on_plan_id is complete
Table plan_dependencies {
id serial [pk]
plan_id uuid [not null, ref: > plans.id]
depends_on_plan_id uuid [not null, ref: > plans.id]
id bigserial [pk]
plan_id bigint [not null, ref: > plans.id]
depends_on_plan_id bigint [not null, ref: > plans.id]
created_at timestamptz [not null, default: `now()`]
indexes {
@@ -43,9 +44,9 @@ Table plan_dependencies {
// Bidirectional: store with plan_a_id < plan_b_id to avoid duplicates
Table plan_related_plans {
id serial [pk]
plan_a_id uuid [not null, ref: > plans.id]
plan_b_id uuid [not null, ref: > plans.id]
id bigserial [pk]
plan_a_id bigint [not null, ref: > plans.id]
plan_b_id bigint [not null, ref: > plans.id]
created_at timestamptz [not null, default: `now()`]
indexes {
@@ -56,9 +57,9 @@ Table plan_related_plans {
}
Table plan_skills {
id serial [pk]
plan_id uuid [not null, ref: > plans.id]
skill_id uuid [not null, ref: > agent_skills.id]
id bigserial [pk]
plan_id bigint [not null, ref: > plans.id]
skill_id bigint [not null, ref: > agent_skills.id]
created_at timestamptz [not null, default: `now()`]
indexes {
@@ -68,9 +69,9 @@ Table plan_skills {
}
Table plan_guardrails {
id serial [pk]
plan_id uuid [not null, ref: > plans.id]
guardrail_id uuid [not null, ref: > agent_guardrails.id]
id bigserial [pk]
plan_id bigint [not null, ref: > plans.id]
guardrail_id bigint [not null, ref: > agent_guardrails.id]
created_at timestamptz [not null, default: `now()`]
indexes {
@@ -80,7 +81,7 @@ Table plan_guardrails {
}
// Cross-file refs (for relspecgo merge)
Ref: plans.project_id > projects.guid [delete: set null]
Ref: plans.project_id > projects.id [delete: set null]
Ref: plans.supersedes_plan_id > plans.id [delete: set null]
Ref: plan_dependencies.plan_id > plans.id [delete: cascade]
Ref: plan_dependencies.depends_on_plan_id > plans.id [delete: cascade]

View File

@@ -1,5 +1,6 @@
Table agent_skills {
id uuid [pk, default: `gen_random_uuid()`]
id bigserial [pk]
guid uuid [unique, not null, default: `gen_random_uuid()`]
name text [unique, not null]
description text [not null, default: '']
content text [not null]
@@ -9,7 +10,8 @@ Table agent_skills {
}
Table agent_guardrails {
id uuid [pk, default: `gen_random_uuid()`]
id bigserial [pk]
guid uuid [unique, not null, default: `gen_random_uuid()`]
name text [unique, not null]
description text [not null, default: '']
content text [not null]
@@ -20,9 +22,9 @@ Table agent_guardrails {
}
Table project_skills {
id serial [pk]
project_id uuid [not null, ref: > projects.guid]
skill_id uuid [not null, ref: > agent_skills.id]
id bigserial [pk]
project_id bigint [not null, ref: > projects.id]
skill_id bigint [not null, ref: > agent_skills.id]
created_at timestamptz [not null, default: `now()`]
indexes {
@@ -32,9 +34,9 @@ Table project_skills {
}
Table project_guardrails {
id serial [pk]
project_id uuid [not null, ref: > projects.guid]
guardrail_id uuid [not null, ref: > agent_guardrails.id]
id bigserial [pk]
project_id bigint [not null, ref: > projects.id]
guardrail_id bigint [not null, ref: > agent_guardrails.id]
created_at timestamptz [not null, default: `now()`]
indexes {
@@ -44,5 +46,7 @@ Table project_guardrails {
}
// Cross-file refs (for relspecgo merge)
Ref: project_skills.project_id > projects.guid [delete: cascade]
Ref: project_guardrails.project_id > projects.guid [delete: cascade]
Ref: project_skills.project_id > projects.id [delete: cascade]
Ref: project_skills.skill_id > agent_skills.id [delete: cascade]
Ref: project_guardrails.project_id > projects.id [delete: cascade]
Ref: project_guardrails.guardrail_id > agent_guardrails.id [delete: cascade]