import type { Knex } from "knex"; import type InformationSchemaColumn from "../information_schema/InformationSchemaColumn.ts"; import type InformationSchemaView from "../information_schema/InformationSchemaView.ts"; import type PgType from "./PgType.ts"; /** * Column type in a foreign table. */ export type ForeignTableColumnType = { /** * Qualified name of the type. */ fullName: string; /** * Kind of the type. */ kind: "base" | "range" | "domain" | "composite" | "enum"; }; /** * Column in a foreign table. */ export interface ForeignTableColumn { /** * Column name. */ name: string; /** * Expanded type name. If the type is an array, brackets will be appended * to the type name. */ expandedType: string; /** * Type information. */ type: ForeignTableColumnType; /** * Comment on the column. */ comment: string | null; /** * Default value of the column. */ defaultValue: any; /** * Whether the column is an array. */ isArray: boolean; /** * Maximum length of the column. */ maxLength: number | null; /** * Behavior of the generated column. "ALWAYS" if always generated, * "NEVER" if never generated, "BY DEFAULT" if generated when a value * is not provided. */ generated: "ALWAYS" | "NEVER" | "BY DEFAULT"; /** * Whether the column is updatable. */ isUpdatable: boolean; /** * Whether the column is an identity column. */ isIdentity: boolean; /** * Ordinal position of the column in the view. Starts from 1. */ ordinalPosition: number; /** * This will contain a "link" to the source table or view and column, * if it can be determined. */ source: { schema: string; table: string; column: string; } | null; /** * Whether the column is nullable. This is only present if the view is * resolved. */ isNullable?: boolean; /** * Whether the column is a primary key. This is only present if the view is * resolved. */ isPrimaryKey?: boolean; /** * Information schema value for the column. */ informationSchemaValue: InformationSchemaColumn; } /** * Foreign table in a schema. */ export interface ForeignTableDetails extends PgType<"foreignTable"> { /** * Information schema value for the view. */ informationSchemaValue: InformationSchemaView; /** * Columns in the view. */ columns: ForeignTableColumn[]; } declare const extractForeignTable: (db: Knex, foreignTable: PgType<"foreignTable">) => Promise; export default extractForeignTable;