This commit is contained in:
2026-07-30 07:19:07 +01:00
parent 246c42a214
commit 0420d50f15
43 changed files with 1942 additions and 219 deletions
+52
View File
@@ -0,0 +1,52 @@
import type { BUN_MARIADB_FieldSchemaType, BUN_MARIADB_TableSchemaType, BunMariaDBConfig } from "../../types";
export type DesiredForeignKey = {
name: string;
column: string;
refTable: string;
refColumn: string;
cascadeDelete: boolean;
cascadeUpdate: boolean;
field: BUN_MARIADB_FieldSchemaType;
};
export type LiveForeignKey = {
name: string;
column: string;
refTable: string;
refColumn: string;
deleteRule: string;
updateRule: string;
};
export declare function grabDesiredForeignKeys(table: BUN_MARIADB_TableSchemaType): DesiredForeignKey[];
export declare function grabLiveForeignKeys({ tableName, config, }: {
tableName: string;
config?: BunMariaDBConfig;
}): Promise<LiveForeignKey[]>;
export declare function dropForeignKey({ tableName, constraintName, config, }: {
tableName: string;
constraintName: string;
config?: BunMariaDBConfig;
}): Promise<void>;
export declare function dropForeignKeysOnColumns({ tableName, columns, config, }: {
tableName: string;
columns: string[];
config?: BunMariaDBConfig;
}): Promise<void>;
/**
* Drop foreign keys that are removed from schema or need recreation
* (name/cascade/target changed). Run before index cleanup.
*/
export declare function dropObsoleteForeignKeys({ table, config, }: {
table: BUN_MARIADB_TableSchemaType;
config?: BunMariaDBConfig;
}): Promise<void>;
/**
* Ensure all desired foreign keys exist. Run after indexes/uniques.
*/
export declare function ensureForeignKeys({ table, config, }: {
table: BUN_MARIADB_TableSchemaType;
config?: BunMariaDBConfig;
}): Promise<void>;
export default function syncForeignKeys({ table, config, }: {
table: BUN_MARIADB_TableSchemaType;
config?: BunMariaDBConfig;
}): Promise<void>;