diff --git a/src/connections/sqlite/cloudflare.ts b/src/connections/sqlite/cloudflare.ts index ddf0b8e..6cd95c0 100644 --- a/src/connections/sqlite/cloudflare.ts +++ b/src/connections/sqlite/cloudflare.ts @@ -250,6 +250,10 @@ export class CloudflareD1Connection extends SqliteBaseConnection { }); } + const columnConstraint = fkConstraintData.find( + (fk) => fk.from === column.name + ); + const currentColumn: TableColumn = { name: column.name, position: column.cid, @@ -259,6 +263,12 @@ export class CloudflareD1Connection extends SqliteBaseConnection { default: column.dflt_value, primaryKey: column.pk === 1, unique: column.pk === 1, + references: columnConstraint + ? { + column: [columnConstraint.to], + table: columnConstraint.table, + } + : undefined, }, }; diff --git a/tests/connections/connection.test.ts b/tests/connections/connection.test.ts index a0b89a0..0c3bde2 100644 --- a/tests/connections/connection.test.ts +++ b/tests/connections/connection.test.ts @@ -14,6 +14,15 @@ afterAll(async () => { await db.disconnect(); }); +afterEach(async () => { + if ( + ['cloudflare', 'bigquery'].includes(process.env.CONNECTION_TYPE ?? '') + ) { + // 3 seconds delay on each operation + await new Promise((r) => setTimeout(r, 3000)); + } +}); + function cleanup(data: Record[]) { // Remove some database specified fields return data.map((d) => {