Documentation
¶
Index ¶
- Constants
- func ActionableSchemaParityError(err error) error
- func BaselineLegacySchemaVersion(db *gorm.DB, migrator *gomigrate.Migrate, ...) (bool, error)
- func CheckSchemaVersion(db *gorm.DB, requiredSchemaVersion int) error
- func EnsureSchemaVersion(db *gorm.DB, driver, dsn, migrationsDir string) error
- func MigrateLegacyDefaultNamespace(db *gorm.DB) error
- func PostgresColumnDataType(db *gorm.DB, tableName, columnName string) (string, error)
- func PostgresColumnNotNull(db *gorm.DB, tableName, columnName string) (bool, error)
- func PostgresIndexExists(db *gorm.DB, indexName string) (bool, error)
- func PostgresTriggerExists(db *gorm.DB, triggerName string) (bool, error)
- func RequiredSchemaTables() []string
- func Run(db *gorm.DB, driver, migrationsDir string, baseline LegacyBaselineFunc, ...) error
- func RunMigrations(db *gorm.DB, driver, migrationsDir string) error
- func SQLiteColumnExists(db *gorm.DB, tableName, columnName string) (bool, error)
- func SQLiteColumnInfo(db *gorm.DB, tableName, columnName string) (struct{ ... }, error)
- func SQLiteColumnNotNull(db *gorm.DB, tableName, columnName string) (bool, error)
- func ShouldAutoMigrateLocalSQLite(driver, dsn string) bool
- func ValidateSchemaForRuntime(db *gorm.DB, driver string, autoMigrated bool) error
- func ValidateSchemaParity(db *gorm.DB, driver string) error
- type LegacyBaselineFunc
- type MigrationSchemaVersion
- type SchemaColumn
- type SchemaTypeCheck
- type SourceInfo
- type ValidateSchemaParityFunc
Constants ¶
const ( RequiredSchemaVersion = 4 SchemaVersionKey = "schema" LegacySchemaVersionTable = "ccg_schema_versions" )
Variables ¶
This section is empty.
Functions ¶
func ActionableSchemaParityError ¶
ActionableSchemaParityError wraps a schema-parity error with recommended remediation steps. @intent 외부 호출자도 동일한 운영 지침 메시지를 재사용하게 한다.
func BaselineLegacySchemaVersion ¶
func BaselineLegacySchemaVersion(db *gorm.DB, migrator *gomigrate.Migrate, driver, schemaVersionKey, legacySchemaTable string, requiredSchemaVersion int) (bool, error)
BaselineLegacySchemaVersion aligns legacy schema versions to golang-migrate metadata. @intent legacy 버전 테이블만 있는 배포를 golang-migrate 메타데이터로 안전하게 기준선 맞춤한다. @domainRule legacy 버전과 실제 스키마 정합성이 모두 맞을 때만 baseline force를 수행한다.
func CheckSchemaVersion ¶
CheckSchemaVersion verifies the current schema migration metadata and dirty state. @intent schema_migrations 메타데이터가 현재 바이너리의 요구 버전과 호환되는지 확인한다. @domainRule dirty migration 상태는 런타임 시작 전에 반드시 실패시킨다.
func EnsureSchemaVersion ¶
EnsureSchemaVersion prepares the database for runtime use, including optional auto-migration. @intent 런타임 명령이 시작되기 전에 스키마 버전과 자동 마이그레이션 조건을 검증한다. @domainRule 기본 로컬 sqlite + 비초기화 상태일 때만 자동 마이그레이션을 허용한다.
func MigrateLegacyDefaultNamespace ¶
MigrateLegacyDefaultNamespace backfills legacy empty namespace rows to the default namespace. @intent namespace 도입 이전 데이터셋을 기본 namespace로 올려 현재 모델과 호환시킨다. @sideEffect nodes, edges, search_documents, communities, flows의 namespace를 갱신한다.
func PostgresColumnDataType ¶
PostgresColumnDataType returns PostgreSQL data_type for a column. @intent 외부 검증 코드가 PostgreSQL 컬럼 타입을 재사용 가능한 API로 확인하게 한다.
func PostgresColumnNotNull ¶
PostgresColumnNotNull checks if a Postgres column is NOT NULL. @intent 외부 검증 코드가 PostgreSQL 컬럼 nullability를 재사용 가능한 API로 확인하게 한다.
func PostgresIndexExists ¶
PostgresIndexExists checks whether a Postgres index exists. @intent 외부 검증 코드가 Postgres 인덱스 존재 여부를 재사용 가능한 API로 확인하게 한다.
func PostgresTriggerExists ¶
PostgresTriggerExists checks whether a non-internal Postgres trigger exists. @intent 외부 검증 코드가 Postgres 트리거 존재 여부를 재사용 가능한 API로 확인하게 한다.
func RequiredSchemaTables ¶
func RequiredSchemaTables() []string
RequiredSchemaTables lists every core table that must exist before runtime commands proceed. @intent 스키마 정합성 검사가 공통으로 확인할 필수 테이블 집합을 제공한다.
func Run ¶
func Run(db *gorm.DB, driver, migrationsDir string, baseline LegacyBaselineFunc, validateSchemaParity ValidateSchemaParityFunc) error
Run executes all pending migrations and validates schema parity. @intent 마이그레이션 실행과 사후 스키마 정합성 검사를 하나의 진입점으로 묶는다. @sideEffect 데이터베이스 스키마와 migration metadata를 변경할 수 있다.
func RunMigrations ¶
RunMigrations executes application migrations with legacy schema baseline handling. @intent 애플리케이션 기본 마이그레이션 경로에 legacy baseline 로직을 포함시킨다.
func SQLiteColumnExists ¶
SQLiteColumnExists checks if a column exists in a SQLite table. @intent 외부 호출자가 SQLite 컬럼 존재 여부를 내부 helper 재사용으로 확인하게 한다.
func SQLiteColumnInfo ¶
func SQLiteColumnInfo(db *gorm.DB, tableName, columnName string) (struct { Exists bool NotNull bool }, error)
SQLiteColumnInfo returns internal metadata for a SQLite column. @intent SQLite 컬럼 메타데이터를 공개형 struct로 노출해 테스트와 검증 코드에서 재사용하게 한다.
func SQLiteColumnNotNull ¶
SQLiteColumnNotNull checks if a SQLite column is defined as NOT NULL. @intent 외부 호출자가 SQLite 컬럼 nullability를 내부 helper 재사용으로 확인하게 한다.
func ShouldAutoMigrateLocalSQLite ¶
ShouldAutoMigrateLocalSQLite determines whether SQLite should auto-migrate for this DSN. @intent 자동 마이그레이션을 기본 로컬 ccg.db 같은 안전한 sqlite 경로로만 제한한다. @domainRule 메모리 DB나 커스텀 파일명은 자동 마이그레이션 대상이 아니다.
func ValidateSchemaForRuntime ¶
ValidateSchemaForRuntime validates schema parity and logs actionable results. @intent 런타임 시작 전에 스키마 이상을 운영 로그와 함께 명확히 보고한다. @sideEffect 성공/실패 결과를 slog에 기록한다.
Types ¶
type LegacyBaselineFunc ¶
LegacyBaselineFunc performs legacy-schema migration fallback during normal migration. @intent 일반 마이그레이션 전에 legacy 스키마를 현재 메타데이터 체계에 정렬하는 훅 계약을 정의한다.
type MigrationSchemaVersion ¶
type MigrationSchemaVersion struct {
Version uint `gorm:"column:version"`
Dirty bool `gorm:"column:dirty"`
}
MigrationSchemaVersion mirrors a row from schema_migrations table. @intent golang-migrate 메타데이터 테이블을 런타임 검증에서 읽을 수 있게 한다.
type SchemaColumn ¶
SchemaColumn represents a required table/column pair. @intent 런타임 스키마 검증에서 필수 컬럼 목록을 표준 구조로 표현한다.
func ModelNullabilityColumns ¶
func ModelNullabilityColumns() []SchemaColumn
ModelNullabilityColumns enumerates columns that must remain NOT NULL for model invariants. @intent 주요 모델 필드의 nullable drift를 런타임 검증에서 감지한다.
type SchemaTypeCheck ¶
SchemaTypeCheck represents a required column type assertion. @intent 특정 컬럼의 데이터 타입까지 검증해야 하는 조건을 표현한다.
type SourceInfo ¶
SourceInfo describes how migration files are sourced. @intent 마이그레이션 파일이 embedded인지 external인지와 사용 드라이버를 함께 기록한다.
func NewMigrator ¶
NewMigrator creates a new golang-migrate instance. @intent GORM DB와 migration source를 golang-migrate 실행 인스턴스로 결합한다.
func SourceInfoFor ¶
func SourceInfoFor(driver, migrationsDir string) (SourceInfo, error)
SourceInfoFor returns the resolved migration source for a driver. @intent 운영 코드와 테스트가 실제 마이그레이션 소스 결정을 외부에서 확인하게 한다.