-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2200 from NMDSdevopsServiceAdm/test2live
Deploy Staging to Preprod
- Loading branch information
Showing
18 changed files
with
773 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
up: (queryInterface, Sequelize) => { | ||
return queryInterface.sequelize.transaction(t => { | ||
Promise.all([ | ||
queryInterface.addColumn( | ||
{ | ||
tableName: 'Establishment', | ||
schema: 'cqc', | ||
}, | ||
'IsRegulatedSavedAt', | ||
{ | ||
type: Sequelize.DataTypes.DATE, | ||
allowNull: true | ||
}, | ||
{ | ||
transaction: t | ||
} | ||
), | ||
queryInterface.addColumn( | ||
{ | ||
tableName: 'Establishment', | ||
schema: 'cqc', | ||
}, | ||
'IsRegulatedChangedAt', | ||
{ | ||
type: Sequelize.DataTypes.DATE, | ||
allowNull: true | ||
}, | ||
{ | ||
transaction: t | ||
} | ||
), | ||
queryInterface.addColumn( | ||
{ | ||
tableName: 'Establishment', | ||
schema: 'cqc', | ||
}, | ||
'IsRegulatedSavedBy', | ||
{ | ||
type: Sequelize.DataTypes.TEXT, | ||
allowNull: true | ||
}, | ||
{ | ||
transaction: t | ||
} | ||
), | ||
queryInterface.addColumn( | ||
{ | ||
tableName: 'Establishment', | ||
schema: 'cqc', | ||
}, | ||
'IsRegulatedChangedBy', | ||
{ | ||
type: Sequelize.DataTypes.TEXT, | ||
allowNull: true | ||
}, | ||
{ | ||
transaction: t | ||
} | ||
) | ||
]); | ||
}); | ||
}, | ||
|
||
down: (queryInterface, Sequelize) => { | ||
return queryInterface.sequelize.transaction(t => { | ||
Promise.all([ | ||
queryInterface.removeColumn( | ||
{ | ||
tableName: 'Establishment', | ||
schema: 'cqc' | ||
}, | ||
'IsRegulatedSavedAt', | ||
{ | ||
transaction: t | ||
} | ||
), | ||
queryInterface.removeColumn( | ||
{ | ||
tableName: 'Establishment', | ||
schema: 'cqc' | ||
}, | ||
'IsRegulatedChangedAt', | ||
{ | ||
transaction: t | ||
} | ||
), | ||
queryInterface.removeColumn( | ||
{ | ||
tableName: 'Establishment', | ||
schema: 'cqc' | ||
}, | ||
'IsRegulatedSavedBy', | ||
{ | ||
transaction: t | ||
} | ||
), | ||
queryInterface.removeColumn( | ||
{ | ||
tableName: 'Establishment', | ||
schema: 'cqc' | ||
}, | ||
'IsRegulatedChangedBy', | ||
{ | ||
transaction: t | ||
} | ||
) | ||
]); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
server/models/classes/establishment/properties/isRegulatedProperty.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// the IsRegulated property is a value property only | ||
const ChangePropertyPrototype = require('../../properties/changePrototype').ChangePropertyPrototype; | ||
const values = [true, false]; | ||
|
||
exports.IsRegulatedProperty = class IsRegulatedProperty extends ChangePropertyPrototype { | ||
constructor() { | ||
super('IsRegulated'); | ||
} | ||
|
||
static clone() { | ||
return new IsRegulatedProperty(); | ||
} | ||
|
||
// concrete implementations | ||
async restoreFromJson(document) { | ||
if (values.includes(document.isRegulated)) { | ||
this.property = document.isRegulated; | ||
} | ||
} | ||
|
||
restorePropertyFromSequelize(document) { | ||
return document.isRegulated; | ||
} | ||
savePropertyToSequelize() { | ||
return { | ||
isRegulated: this.property | ||
}; | ||
} | ||
|
||
isEqual(currentValue, newValue) { | ||
// employer type is a simple string | ||
return currentValue && newValue && currentValue === newValue; | ||
} | ||
|
||
toJSON(withHistory=false, showPropertyHistoryOnly=true) { | ||
if (!withHistory) { | ||
// simple form | ||
return { | ||
isRegulated: this.property | ||
}; | ||
} | ||
|
||
return { | ||
isRegulated: { | ||
currentValue: this.property, | ||
... this.changePropsToJSON(showPropertyHistoryOnly) | ||
} | ||
}; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.