Skip to content

Commit 72d88b1

Browse files
committed
fix @@unique naming uniqueness
1 parent ecf09c8 commit 72d88b1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/schema/src/plugins/prisma/schema-generator.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ export class PrismaSchemaGenerator {
481481

482482
private replicateForeignKey(
483483
model: PrismaDataModel,
484-
dataModel: DataModel,
484+
delegateModel: DataModel,
485485
concreteModel: DataModel,
486486
origForeignKey: DataModelField
487487
) {
@@ -499,15 +499,15 @@ export class PrismaSchemaGenerator {
499499
(attr) => !('name' in attr && attr.name === '@unique')
500500
);
501501
const uniqueAttr = addedFkField.addAttribute('@unique');
502-
const constraintName = this.truncate(`${concreteModel.name}_${addedFkField.name}_unique`);
502+
const constraintName = this.truncate(`${delegateModel.name}_${addedFkField.name}_${concreteModel.name}_unique`);
503503
uniqueAttr.args.push(new PrismaAttributeArg('map', new AttributeArgValue('String', constraintName)));
504504

505505
// fix its name
506-
const addedFkFieldName = `${dataModel.name}_${origForeignKey.name}_${concreteModel.name}`;
506+
const addedFkFieldName = `${delegateModel.name}_${origForeignKey.name}_${concreteModel.name}`;
507507
addedFkField.name = this.truncate(`${DELEGATE_AUX_RELATION_PREFIX}_${addedFkFieldName}`);
508508

509509
// we also need to go through model-level `@@unique` and replicate those involving fk fields
510-
this.replicateForeignKeyModelLevelUnique(model, dataModel, origForeignKey, addedFkField);
510+
this.replicateForeignKeyModelLevelUnique(model, delegateModel, origForeignKey, addedFkField);
511511

512512
return addedFkField;
513513
}

0 commit comments

Comments
 (0)