feat: naming strategy (#19848)

* feat: naming strategy

* feat: detect renames
This commit is contained in:
Jason Rasmussen
2025-07-11 11:35:10 -04:00
committed by GitHub
parent 1d19d308e2
commit 9e48ae3052
35 changed files with 517 additions and 127 deletions

View File

@@ -1,4 +1,3 @@
import { asKey } from 'src/sql-tools/helpers';
import { ConstraintType, Processor } from 'src/sql-tools/types';
export const processPrimaryKeyConstraints: Processor = (ctx) => {
@@ -15,7 +14,13 @@ export const processPrimaryKeyConstraints: Processor = (ctx) => {
const tableMetadata = ctx.getTableMetadata(table);
table.constraints.push({
type: ConstraintType.PRIMARY_KEY,
name: tableMetadata.options.primaryConstraintName || asPrimaryKeyConstraintName(table.name, columnNames),
name:
tableMetadata.options.primaryConstraintName ||
ctx.getNameFor({
type: 'primaryKey',
tableName: table.name,
columnNames,
}),
tableName: table.name,
columnNames,
synchronize: tableMetadata.options.synchronize ?? true,
@@ -23,5 +28,3 @@ export const processPrimaryKeyConstraints: Processor = (ctx) => {
}
}
};
const asPrimaryKeyConstraintName = (table: string, columns: string[]) => asKey('PK_', table, columns);