From ed0bdd2cfd4ac072058ee65524561a968c8a7ffa Mon Sep 17 00:00:00 2001 From: vlaznim-mustafa Date: Mon, 12 Feb 2024 16:42:18 +0100 Subject: [PATCH] Add enum references method --- pattern/typical/enum-table.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pattern/typical/enum-table.ts b/pattern/typical/enum-table.ts index 4fa3aa36..dee87813 100644 --- a/pattern/typical/enum-table.ts +++ b/pattern/typical/enum-table.ts @@ -4,10 +4,18 @@ import * as SQLa from "../../render/mod.ts"; // deno-lint-ignore no-explicit-any type Any = any; // make it easier on Deno linting +interface ForeignKeyReference { + tableName: string; + columnName: string; + constraints?: string; +} export interface EnumTableDefn { readonly enumTableNature: "text" | "numeric"; readonly seedDML: string | SQLa.SqlTextSupplier[]; + references: { + code: () => ForeignKeyReference; + } } export function isEnumTableDefn( @@ -137,6 +145,14 @@ export function ordinalEnumTable< seedDML: seedRows && seedRows.length > 0 ? seedRows.map((s) => tdrf.insertDML(s as Any)) : `-- no ${tableName} seed rows`, + references: { + code: () => { + return { + tableName: tableName, + columnName: 'code', + }; + } + } }; const td = SQLa.tableDefinition(tableName, columnsShape, tdOptions); return {