Skip to content

Commit

Permalink
Add quarterly returns to return versions table
Browse files Browse the repository at this point in the history
https://eaflood.atlassian.net/browse/WATER-4707

As part of the work to introduce quarterly returns in the system repo we need to add a column to mark a return version for quarterly returns.

The work to handle this logic is done in the system repo.

This change is just to introduce the quarterly returns in the previous water tables.
  • Loading branch information
jonathangoulding committed Nov 7, 2024
1 parent 6969d1c commit 756f99b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use strict';

const fs = require('fs');
const path = require('path');
let Promise;

/**
* We receive the dbmigrate dependency from dbmigrate initially.
* This enables us to not have to rely on NODE_PATH.
*/
exports.setup = function(options, _seedLink) {
Promise = options.Promise;
};

exports.up = function(db) {
var filePath = path.join(__dirname, 'sqls', '20241107093135-add-quarterly-returns-to-return-versions-up.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
if (err) return reject(err);
console.log('received data: ' + data);

resolve(data);
});
})
.then(function(data) {
return db.runSql(data);
});
};

exports.down = function(db) {
var filePath = path.join(__dirname, 'sqls', '20241107093135-add-quarterly-returns-to-return-versions-down.sql');
return new Promise( function( resolve, reject ) {
fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){
if (err) return reject(err);
console.log('received data: ' + data);

resolve(data);
});
})
.then(function(data) {
return db.runSql(data);
});
};

exports._meta = {
version: 1
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table water.return_versions
drop column quarterly_returns;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table water.return_versions
add column quarterly_returns boolean default false;

0 comments on commit 756f99b

Please sign in to comment.