@@ -23,7 +23,7 @@ import (
2323)
2424
2525const (
26- RequiredSchemaVersion = 13
26+ RequiredSchemaVersion = 14
2727 SchemaVersionKey = "schema"
2828 LegacySchemaVersionTable = "ccg_schema_versions"
2929)
@@ -388,6 +388,57 @@ func RequiredSchemaTables() []string {
388388 }
389389}
390390
391+ // RequiredTextColumns lists graph string columns that must remain unbounded across database drivers.
392+ // @intent prevent source-derived graph values from failing persistence because of arbitrary varchar widths.
393+ func RequiredTextColumns () []SchemaColumn {
394+ return []SchemaColumn {
395+ {Table : "nodes" , Column : "namespace" },
396+ {Table : "nodes" , Column : "qualified_name" },
397+ {Table : "nodes" , Column : "kind" },
398+ {Table : "nodes" , Column : "name" },
399+ {Table : "nodes" , Column : "file_path" },
400+ {Table : "nodes" , Column : "hash" },
401+ {Table : "nodes" , Column : "language" },
402+ {Table : "edges" , Column : "namespace" },
403+ {Table : "edges" , Column : "kind" },
404+ {Table : "edges" , Column : "file_path" },
405+ {Table : "edges" , Column : "fingerprint" },
406+ {Table : "annotations" , Column : "summary" },
407+ {Table : "annotations" , Column : "context" },
408+ {Table : "annotations" , Column : "raw_text" },
409+ {Table : "doc_tags" , Column : "kind" },
410+ {Table : "doc_tags" , Column : "type" },
411+ {Table : "doc_tags" , Column : "name" },
412+ {Table : "doc_tags" , Column : "value" },
413+ {Table : "communities" , Column : "namespace" },
414+ {Table : "communities" , Column : "key" },
415+ {Table : "communities" , Column : "label" },
416+ {Table : "communities" , Column : "strategy" },
417+ {Table : "communities" , Column : "description" },
418+ {Table : "flows" , Column : "namespace" },
419+ {Table : "flows" , Column : "name" },
420+ {Table : "flows" , Column : "description" },
421+ {Table : "flow_memberships" , Column : "namespace" },
422+ {Table : "search_documents" , Column : "namespace" },
423+ {Table : "search_documents" , Column : "content" },
424+ {Table : "search_documents" , Column : "language" },
425+ {Table : "parse_cache_entries" , Column : "namespace" },
426+ {Table : "parse_cache_entries" , Column : "file_path" },
427+ {Table : "parse_cache_entries" , Column : "source_hash" },
428+ {Table : "parse_cache_entries" , Column : "parser_version" },
429+ {Table : "parse_cache_entries" , Column : "context_hash" },
430+ {Table : "unresolved_edge_candidates" , Column : "namespace" },
431+ {Table : "unresolved_edge_candidates" , Column : "lookup_key" },
432+ {Table : "unresolved_edge_candidates" , Column : "lookup_key_hash" },
433+ {Table : "unresolved_edge_candidates" , Column : "fingerprint" },
434+ {Table : "unresolved_edge_candidates" , Column : "fingerprint_hash" },
435+ {Table : "unresolved_edge_candidates" , Column : "file_path" },
436+ {Table : "unresolved_edge_candidates" , Column : "kind" },
437+ {Table : "unresolved_index_states" , Column : "namespace" },
438+ {Table : "unresolved_index_states" , Column : "version" },
439+ }
440+ }
441+
391442// ModelNullabilityColumns enumerates columns that must remain NOT NULL for model invariants.
392443// @intent 주요 모델 필드의 nullable drift를 런타임 검증에서 감지한다.
393444func ModelNullabilityColumns () []SchemaColumn {
@@ -585,7 +636,7 @@ func validateSQLiteSchemaParity(db *gorm.DB) error {
585636 return nil
586637}
587638
588- // validatePostgresSchemaParity checks PostgreSQL-only indexes, triggers, and JSONB column types.
639+ // validatePostgresSchemaParity checks PostgreSQL-only indexes, triggers, and column types.
589640// @intent PostgreSQL 검색/후처리 스키마가 운영 계약과 일치하는지 확인한다.
590641func validatePostgresSchemaParity (db * gorm.DB ) error {
591642 for _ , column := range ModelNullabilityColumns () {
@@ -621,13 +672,10 @@ func validatePostgresSchemaParity(db *gorm.DB) error {
621672 return fmt .Errorf ("required index %q is missing" , indexName )
622673 }
623674 }
624- for _ , column := range []SchemaColumn {
625- {Table : "annotations" , Column : "summary" },
626- {Table : "annotations" , Column : "context" },
627- } {
675+ for _ , column := range RequiredTextColumns () {
628676 dataType , err := postgresColumnDataType (db , column .Table , column .Column )
629677 if err != nil {
630- return trace .Wrap (err , "inspect postgres annotation column type" )
678+ return trace .Wrap (err , "inspect postgres text column type" )
631679 }
632680 if dataType != "text" {
633681 return fmt .Errorf ("required column %q.%q has type %q, want text" , column .Table , column .Column , dataType )
0 commit comments