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
@@ -0,0 +1,11 @@
'use strict';

module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.renameColumn('Microservices', 'updated_by', 'user_id')
},

down: (queryInterface, Sequelize) => {
return queryInterface.renameColumn('Microservices', 'user_id', 'updated_by')
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.renameColumn('MicroservicePorts', 'updated_by', 'user_id')
},

down: (queryInterface, Sequelize) => {
return queryInterface.renameColumn('MicroservicePorts', 'user_id', 'updated_by')
}
};
14 changes: 14 additions & 0 deletions src/sequelize/migrations/20181109132723-flow-remove-updatedBy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.removeColumn('Flows', 'updated_by')
},

down: (queryInterface, Sequelize) => {
return queryInterface.addColumn('Flows',
'updated_by',
Sequelize.INTEGER
)
}
};
9 changes: 0 additions & 9 deletions src/sequelize/models/flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,6 @@ module.exports = (sequelize, DataTypes) => {
onDelete: 'cascade'
});

Flow.belongsTo(models.User, {
foreignKey: {
name: 'updatedById',
field: 'updated_by'
},
as: 'updatedBy',
onDelete: 'set null'
});

Flow.hasMany(models.Microservice, {
foreignKey: {
name: 'flowId',
Expand Down
4 changes: 2 additions & 2 deletions src/sequelize/models/microservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ module.exports = (sequelize, DataTypes) => {

Microservice.belongsTo(models.User, {
foreignKey: {
name: 'updatedBy',
field: 'updated_by'
name: 'userId',
field: 'user_id'
},
as: 'user',
onDelete: 'cascade'
Expand Down
4 changes: 2 additions & 2 deletions src/sequelize/models/microserviceport.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ module.exports = (sequelize, DataTypes) => {

MicroservicePort.belongsTo(models.User, {
foreignKey: {
name: 'updatedBy',
field: 'updated_by'
name: 'userId',
field: 'user_id'
},
as: 'user',
onDelete: 'cascade'
Expand Down
8 changes: 8 additions & 0 deletions src/sequelize/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ module.exports = (sequelize, DataTypes) => {
as: 'fog'
});

User.hasMany(models.Microservice, {
foreignKey: {
name: 'userId',
field: 'user_id'
},
as: 'microservice'
});

};
return User;
};
4 changes: 2 additions & 2 deletions src/services/diagnostic-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const postMicroserviceImageSnapshotCreate = async function (microserviceUuid, us
:
{
uuid: microserviceUuid,
updatedBy: user.id
userId: user.id
};


Expand All @@ -108,7 +108,7 @@ const getMicroserviceImageSnapshot = async function (microserviceUuid, user, isC
:
{
uuid: microserviceUuid,
updatedBy: user.id
userId: user.id
};
const microservice = await MicroserviceManager.findOneWithDependencies(where, {}, transaction);
if (microservice.iofogUuid === null) {
Expand Down
1 change: 0 additions & 1 deletion src/services/flow-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ const _updateFlow = async function (flowData, flowId, user, isCLI, transaction)
name: flowData.name,
description: flowData.description,
isActivated: flowData.isActivated,
updatedBy: user.id
};

const updateFlowData = AppHelper.deleteUndefinedFields(flow);
Expand Down
8 changes: 4 additions & 4 deletions src/services/iofog-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async function _createFog(fogData, user, isCli, transaction) {
iofogUuid: fog.uuid,
rootHostAccess: true,
logSize: 50,
updatedBy: user.id,
userId: user.id,
configLastUpdated: Date.now()
};

Expand All @@ -97,7 +97,7 @@ async function _createFog(fogData, user, isCli, transaction) {
iofogUuid: fog.uuid,
rootHostAccess: true,
logSize: 50,
updatedBy: user.id,
userId: user.id,
configLastUpdated: Date.now()
};

Expand Down Expand Up @@ -174,7 +174,7 @@ async function _updateFog(fogData, user, isCli, transaction) {
iofogUuid: fogData.uuid,
rootHostAccess: true,
logSize: 50,
updatedBy: user.id,
userId: user.id,
configLastUpdated: Date.now()
};

Expand Down Expand Up @@ -206,7 +206,7 @@ async function _updateFog(fogData, user, isCli, transaction) {
iofogUuid: fogData.uuid,
rootHostAccess: true,
logSize: 50,
updatedBy: user.id,
userId: user.id,
configLastUpdated: Date.now()
};

Expand Down
32 changes: 16 additions & 16 deletions src/services/microservices-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const _createMicroservice = async function (microserviceData, user, isCLI, trans
iofogUuid: microserviceData.iofogUuid,
rootHostAccess: microserviceData.rootHostAccess,
logSize: microserviceData.logLimit,
updatedBy: user.id
userId: user.id
};

newMicroservice = AppHelper.deleteUndefinedFields(newMicroservice);
Expand Down Expand Up @@ -150,14 +150,14 @@ const _updateMicroservice = async function (microserviceUuid, microserviceData,
rootHostAccess: microserviceData.rootHostAccess,
logSize: microserviceData.logLimit,
volumeMappings: microserviceData.volumeMappings,
updatedBy: user.id
userId: user.id
};

const microserviceDataUpdate = AppHelper.deleteUndefinedFields(microserviceToUpdate);

const microservice = await MicroserviceManager.findOne({
uuid: microserviceUuid,
updatedBy: user.id
userId: user.id
}, transaction);

if (microserviceDataUpdate.name) {
Expand Down Expand Up @@ -208,7 +208,7 @@ const _deleteMicroservice = async function (microserviceUuid, deleteWithCleanUp,
?
{
uuid: microserviceUuid,
updatedBy: user.id
userId: user.id
}
:
{
Expand Down Expand Up @@ -257,12 +257,12 @@ const _checkForDuplicateName = async function (name, item, userId, transaction)
{
name: name,
uuid: {[Op.ne]: item.id},
updatedBy: userId
userId: userId
}
:
{
name: name,
updatedBy: userId
userId: userId
};

const result = await MicroserviceManager.findOne(where, transaction);
Expand Down Expand Up @@ -292,7 +292,7 @@ const _validateMicroserviceOnGet = async function (userId, microserviceUuid, tra
async function _createRoute(sourceMicroserviceUuid, destMicroserviceUuid, user, isCLI, transaction) {
const sourceWhere = isCLI
? {uuid: sourceMicroserviceUuid}
: {uuid: sourceMicroserviceUuid, updatedBy: user.id};
: {uuid: sourceMicroserviceUuid, userId: user.id};

const sourceMicroservice = await MicroserviceManager.findOne(sourceWhere, transaction);
if (!sourceMicroservice) {
Expand All @@ -301,7 +301,7 @@ async function _createRoute(sourceMicroserviceUuid, destMicroserviceUuid, user,

const destWhere = isCLI
? {uuid: destMicroserviceUuid}
: {uuid: destMicroserviceUuid, updatedBy: user.id};
: {uuid: destMicroserviceUuid, userId: user.id};

const destMicroservice = await MicroserviceManager.findOne(destWhere, transaction);
if (!destMicroservice) {
Expand Down Expand Up @@ -447,7 +447,7 @@ async function _createNetworkMicroserviceForMaster(masterMicroservice, sourceNet
iofogUuid: masterMicroservice.iofogUuid,
rootHostAccess: false,
logSize: 50,
updatedBy: user.id,
userId: user.id,
configLastUpdated: Date.now()
};

Expand All @@ -468,7 +468,7 @@ async function _switchOnUpdateFlagsForMicroservicesInRoute(sourceMicroservice, d
async function _deleteRoute(sourceMicroserviceUuid, destMicroserviceUuid, user, isCLI, transaction) {
const sourceWhere = isCLI
? {uuid: sourceMicroserviceUuid}
: {uuid: sourceMicroserviceUuid, updatedBy: user.id};
: {uuid: sourceMicroserviceUuid, userId: user.id};

const sourceMicroservice = await MicroserviceManager.findOne(sourceWhere, transaction);
if (!sourceMicroservice) {
Expand All @@ -477,7 +477,7 @@ async function _deleteRoute(sourceMicroserviceUuid, destMicroserviceUuid, user,

const destWhere = isCLI
? {uuid: destMicroserviceUuid}
: {uuid: destMicroserviceUuid, updatedBy: user.id};
: {uuid: destMicroserviceUuid, userId: user.id};

const destMicroservice = await MicroserviceManager.findOne(destWhere, transaction);
if (!destMicroservice) {
Expand Down Expand Up @@ -527,7 +527,7 @@ async function _createPortMapping(microserviceUuid, portMappingData, user, isCLI

const where = isCLI
? {uuid: microserviceUuid}
: {uuid: microserviceUuid, updatedBy: user.id};
: {uuid: microserviceUuid, userId: user.id};

const microservice = await MicroserviceManager.findOne(where, transaction)
if (!microservice) {
Expand Down Expand Up @@ -567,7 +567,7 @@ async function _createSimplePortMapping(microservice, portMappingData, user, tra
isPublic: false,
portInternal: portMappingData.internal,
portExternal: portMappingData.external,
updatedBy: user.id,
userId: user.id,
microserviceUuid: microservice.uuid
}

Expand Down Expand Up @@ -625,7 +625,7 @@ async function _createPortMappingOverConnector(microservice, portMappingData, us
isPublic: true,
portInternal: portMappingData.internal,
portExternal: portMappingData.external,
updatedBy: user.id,
userId: user.id,
microserviceUuid: microservice.uuid
}

Expand Down Expand Up @@ -663,7 +663,7 @@ async function _switchOnUpdateFlagsForMicroservicesForPortMapping(microservice,
async function _deletePortMapping(microserviceUuid, internalPort, user, isCLI, transaction) {
const where = isCLI
? {uuid: microserviceUuid}
: {uuid: microserviceUuid, updatedBy: user.id}
: {uuid: microserviceUuid, userId: user.id}

const microservice = await MicroserviceManager.findOne(where, transaction);
if (!microservice) {
Expand Down Expand Up @@ -748,7 +748,7 @@ async function _buildPortsList(portsPairs, transaction) {
async function _getPortMappingList(microserviceUuid, user, isCLI, transaction) {
const where = isCLI
? {uuid: microserviceUuid}
: {uuid: microserviceUuid, updatedBy: user.id};
: {uuid: microserviceUuid, userId: user.id};
const microservice = await MicroserviceManager.findOne(where, transaction)
if (!microservice) {
throw new Errors.NotFoundError(AppHelper.formatMessage(ErrorMessages.INVALID_MICROSERVICE_UUID, microserviceUuid))
Expand Down