Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,27 @@ const getAddSingleForeignKeyStatementDto = relationship => {
const relationshipName = getRelationshipName(relationship);
const ddlProvider = require('../../ddlProvider/ddlProvider')();

return ddlProvider.createForeignKey({
name: relationshipName,
foreignKey: compMod.child.collection.fkFields,
primaryKey: compMod.parent.collection.fkFields,
customProperties: compMod.customProperties?.new,
foreignTable: compMod.child.collection.name,
foreignSchemaName: compMod.child.bucket.name,
foreignTableActivated: compMod.child.collection.isActivated,
primaryTable: compMod.parent.collection.name,
primarySchemaName: compMod.parent.bucket.name,
primaryTableActivated: compMod.parent.collection.isActivated,
isActivated: Boolean(relationship.role?.compMod?.isActivated?.new),
});
const schemaData = {
schemaName: compMod.child.bucket.name,
};

return ddlProvider.createForeignKey(
{
name: relationshipName,
foreignKey: compMod.child.collection.fkFields,
primaryKey: compMod.parent.collection.fkFields,
customProperties: compMod.customProperties?.new,
foreignTable: compMod.child.collection.name,
foreignSchemaName: compMod.child.bucket.name,
foreignTableActivated: compMod.child.collection.isActivated,
primaryTable: compMod.parent.collection.name,
primarySchemaName: compMod.parent.bucket.name,
primaryTableActivated: compMod.parent.collection.isActivated,
isActivated: Boolean(relationship.role?.compMod?.isActivated?.new),
},
{},
schemaData,
);
};

const canRelationshipBeAdded = relationship => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ const alterPkConstraint = (tableName, isParentActivated, keyData) => {
};

const dropPK = tableName => {
const templatesConfig = { tableName };
return assignTemplates(templates.dropPK, templatesConfig);
const templateData = { tableName };
return assignTemplates({
templates: templates.dropPK,
templateData,
});
};

const alterUkConstraint = (tableName, isParentActivated, keyData) => {
Expand All @@ -69,11 +72,14 @@ const alterUkConstraint = (tableName, isParentActivated, keyData) => {
* @param constraintName {string}
* */
const dropUkConstraint = (tableName, constraintName) => {
const templatesConfig = {
const templateData = {
tableName,
constraintName,
};
return assignTemplates(templates.dropUkConstraint, templatesConfig);
return assignTemplates({
template: templates.dropUkConstraint,
templateData,
});
};

module.exports = {
Expand Down