# Function foreignKey

- foreignKey<
  TTableName extends string,
  TForeignTableName extends string,
  TColumns extends
  [
  AnySQLiteColumn<{ tableName: TTableName }>,
  ...AnySQLiteColumn<{ tableName: TTableName }>[],
  ],
  >(
  config: () => {
  columns: TColumns;
  foreignColumns: ColumnsWithTable<TForeignTableName, TColumns>;
  name?: string;
  },
  ): ForeignKeyBuilder

  #### Type Parameters

  - TTableName extends string
  - TForeignTableName extends string
  - TColumns extends [
    AnySQLiteColumn<{ tableName: TTableName }>,
    ...AnySQLiteColumn<{ tableName: TTableName }>[],
    ]

  #### Parameters

  - config: () => {
    columns: TColumns;
    foreignColumns: ColumnsWithTable<TForeignTableName, TColumns>;
    name?: string;
    }

  #### Returns ForeignKeyBuilder

  #### Deprecated

  please use `foreignKey({ columns: [], foreignColumns: [] })` syntax without callback

  - Defined in node_modules/.pnpm/drizzle-orm@0.44.6_@cloudflare+workers-types@4.20251014.0_@opentelemetry+api@1.9.0_@typ_31a6f5ca8f102af87864dd251ed08d88/node_modules/drizzle-orm/sqlite-core/foreign-keys.d.ts:47
- foreignKey<
  TTableName extends string,
  TForeignTableName extends string,
  TColumns extends
  [
  AnySQLiteColumn<{ tableName: TTableName }>,
  ...AnySQLiteColumn<{ tableName: TTableName }>[],
  ],
  >(
  config: {
  columns: TColumns;
  foreignColumns: ColumnsWithTable<TForeignTableName, TColumns>;
  name?: string;
  },
  ): ForeignKeyBuilder

  #### Type Parameters

  - TTableName extends string
  - TForeignTableName extends string
  - TColumns extends [
    AnySQLiteColumn<{ tableName: TTableName }>,
    ...AnySQLiteColumn<{ tableName: TTableName }>[],
    ]

  #### Parameters

  - config: {
    columns: TColumns;
    foreignColumns: ColumnsWithTable<TForeignTableName, TColumns>;
    name?: string;
    }

  #### Returns ForeignKeyBuilder

  #### Deprecated

  please use `foreignKey({ columns: [], foreignColumns: [] })` syntax without callback

  - Defined in node_modules/.pnpm/drizzle-orm@0.44.6_@cloudflare+workers-types@4.20251014.0_@opentelemetry+api@1.9.0_@typ_31a6f5ca8f102af87864dd251ed08d88/node_modules/drizzle-orm/sqlite-core/foreign-keys.d.ts:56