Skip to content

Commit

Permalink
Removed foreign keys
Browse files Browse the repository at this point in the history
  • Loading branch information
drodrigues4 committed Jul 24, 2024
1 parent da0f7e4 commit 23aa8d2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 164 deletions.
36 changes: 0 additions & 36 deletions drizzle-orm/src/singlestore-core/columns/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,11 @@ import type {
import type { ColumnBaseConfig } from '~/column.ts';
import { Column } from '~/column.ts';
import { entityKind } from '~/entity.ts';
import type { ForeignKey, UpdateDeleteAction } from '~/singlestore-core/foreign-keys.ts';
import { ForeignKeyBuilder } from '~/singlestore-core/foreign-keys.ts';
import type { AnySingleStoreTable, SingleStoreTable } from '~/singlestore-core/table.ts';
import type { SQL } from '~/sql/sql.ts';
import type { Update } from '~/utils.ts';
import { uniqueKeyName } from '../unique-constraint.ts';

export interface ReferenceConfig {
ref: () => SingleStoreColumn;
actions: {
onUpdate?: UpdateDeleteAction;
onDelete?: UpdateDeleteAction;
};
}

export interface SingleStoreColumnBuilderBase<
T extends ColumnBuilderBaseConfig<ColumnDataType, string> = ColumnBuilderBaseConfig<ColumnDataType, string>,
TTypeConfig extends object = object,
Expand All @@ -49,13 +39,6 @@ export abstract class SingleStoreColumnBuilder<
{
static readonly [entityKind]: string = 'SingleStoreColumnBuilder';

private foreignKeyConfigs: ReferenceConfig[] = [];

references(ref: ReferenceConfig['ref'], actions: ReferenceConfig['actions'] = {}): this {
this.foreignKeyConfigs.push({ ref, actions });
return this;
}

unique(name?: string): this {
this.config.isUnique = true;
this.config.uniqueName = name;
Expand All @@ -71,25 +54,6 @@ export abstract class SingleStoreColumnBuilder<
return this as any;
}

/** @internal */
buildForeignKeys(column: SingleStoreColumn, table: SingleStoreTable): ForeignKey[] {
return this.foreignKeyConfigs.map(({ ref, actions }) => {
return ((ref, actions) => {
const builder = new ForeignKeyBuilder(() => {
const foreignColumn = ref();
return { columns: [column], foreignColumns: [foreignColumn] };
});
if (actions.onUpdate) {
builder.onUpdate(actions.onUpdate);
}
if (actions.onDelete) {
builder.onDelete(actions.onDelete);
}
return builder.build(table);
})(ref, actions);
});
}

/** @internal */
abstract build<TTableName extends string>(
table: AnySingleStoreTable<{ name: TTableName }>,
Expand Down
128 changes: 0 additions & 128 deletions drizzle-orm/src/singlestore-core/foreign-keys.ts

This file was deleted.

0 comments on commit 23aa8d2

Please sign in to comment.