Skip to content

Commit

Permalink
Add source system (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnwatson484 authored Aug 2, 2021
1 parent 8e760a8 commit d4f0046
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/data/models/scheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ module.exports = (sequelize, DataTypes) => {
foreignKey: 'schemeId',
as: 'deliveryBody'
})
scheme.hasMany(models.sourceSystem, {
foreignKey: 'schemeId',
as: 'sourceSystems'
})
}
return scheme
}
19 changes: 19 additions & 0 deletions app/data/models/source-system.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = (sequelize, DataTypes) => {
const sourceSystem = sequelize.define('sourceSystem', {
sourceSystemId: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
schemeId: DataTypes.INTEGER,
name: DataTypes.STRING
},
{
tableName: 'sourceSystems',
freezeTableName: true,
timestamps: false
})
sourceSystem.associate = function (models) {
sourceSystem.belongsTo(models.scheme, {
foreignKey: 'schemeId',
as: 'scheme'
})
}
return sourceSystem
}
25 changes: 25 additions & 0 deletions changelog/db.changelog-1.4.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-3.9.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.9.xsd">
<changeSet author="John Watson" id="37">
<createTable tableName="sourceSystems">
<column autoIncrement="true" name="sourceSystemId" type="INTEGER">
<constraints nullable="false" primaryKey="true" primaryKeyName="sourceSystemId_pkey" />
</column>
<column name="schemeId" type="INTEGER" />
<column name="name" type="VARCHAR(50)" />
</createTable>
<insert tableName="sourceSystems">
<column name="sourceSystemId" value="1" />
<column name="schemeId" value="1" />
<column name="name" value="SFIP" />
</insert>
<insert tableName="sourceSystems">
<column name="sourceSystemId" value="2" />
<column name="schemeId" value="1" />
<column name="name" value="ffc-sfi-agreeement-calculator" />
</insert>
</changeSet>
<changeSet author="John Watson" id="38">
<addForeignKeyConstraint baseColumnNames="schemeId" baseTableName="sourceSystems" constraintName="fk_sourceSystems_schemeCodeId" referencedColumnNames="schemeId" referencedTableName="schemes" />
</changeSet>
</databaseChangeLog>
1 change: 1 addition & 0 deletions changelog/db.changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
<include file="changelog/db.changelog-1.1.xml"/>
<include file="changelog/db.changelog-1.2.xml"/>
<include file="changelog/db.changelog-1.3.xml"/>
<include file="changelog/db.changelog-1.4.xml"/>
</databaseChangeLog>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ffc-sfi-payments",
"version": "1.2.0",
"version": "1.3.0",
"description": "FFC SFI payment services",
"homepage": "https://github.com/DEFRA/ffc-sfi-payments",
"main": "app/index.js",
Expand Down

0 comments on commit d4f0046

Please sign in to comment.