import { type Knex } from "knex"; import { type MigrationColumn, type MigrationSet, type RelationOn } from "../types/types"; /** * 특정 테이블의 PK를 참조하는 다른 테이블의 FK 정보입니다. * PK 타입 변경 시 관련 FK 제약조건을 처리하기 위해 사용됩니다. */ export type ReferencingForeignKey = { /** FK가 정의된 테이블명 */ tableName: string; /** FK 제약조건 이름 */ constraintName: string; /** FK 컬럼명 */ columnName: string; /** 참조하는 테이블명 (PK가 있는 테이블) */ referencedTableName: string; /** 참조하는 컬럼명 (보통 'id') */ referencedColumnName: string; /** ON UPDATE 액션 */ onUpdate: RelationOn; /** ON DELETE 액션 */ onDelete: RelationOn; }; export type PgColumn = { column_name: string; data_type: string; udt_name: string; character_maximum_length: number | null; precision: number | null; numeric_scale: number | null; is_nullable: string; column_default: string | null; is_generated: string; generation_expression: string | null; }; type PgIndex = { index_name: string; column_name: string; is_unique: boolean; is_primary: boolean; index_type: string; nulls_first: boolean; sort_order: "ASC" | "DESC"; nulls_not_distinct: boolean; column_order: number; index_definition: string; }; type PgForeign = { constraint_name: string; column_name: string; foreign_table_name: string; foreign_column_name: string; update_rule: string; delete_rule: string; }; type RawCapableKnex = Pick; declare class PostgreSQLSchemaReaderClass { private readonly genericIndexTypes; /** * DB에서 테이블 정보를 읽어서 MigrationSet을 만들어옵니다. * @param compareDB Knex 인스턴스 * @param table 테이블 이름 * @returns MigrationSet 객체 */ getMigrationSetFromDB(compareDB: RawCapableKnex, table: string): Promise; /** * PostgreSQL의 constraint action을 Knex 형식으로 변환 */ private mapConstraintAction; /** * 기존 테이블 읽어서 cols, indexes, foreigns 반환 */ readTable(compareDB: RawCapableKnex, tableName: string): Promise<[PgColumn[], PgIndex[], PgForeign[]]>; private restoreMigrationIndexType; private restoreGenericUsing; private parseVectorIndexOptions; private parseIntegerOption; private extractIndexColumnOpclass; private parseIndexDefinition; private parseIndexOptionEntries; private splitTopLevel; private tokenizeTopLevel; private findMatchingParenthesis; /** * 특정 테이블의 PK를 참조하는 다른 테이블의 FK 목록을 조회합니다. * PK 타입 변경 시 관련 FK 제약조건을 삭제/복구하기 위해 사용됩니다. */ getReferencingForeignKeys(db: Knex, tableName: string): Promise; /** * vector 컬럼의 dimensions를 조회합니다. * pg_attribute의 atttypmod에서 차원 수를 추출합니다. */ private getVectorDimensions; /** * PostgreSQL 컬럼 타입을 분석하여 MigrationColumn 객체로 변환합니다. */ resolveDBColType(dbColumn: PgColumn): Pick; } export declare const PostgreSQLSchemaReader: PostgreSQLSchemaReaderClass; export {}; //# sourceMappingURL=postgresql-schema-reader.d.ts.map