diff --git a/database/migrations/20220311021020-AddSubOrganization.js b/database/migrations/20220311021020-AddSubOrganization.js new file mode 100644 index 0000000..21e73a3 --- /dev/null +++ b/database/migrations/20220311021020-AddSubOrganization.js @@ -0,0 +1,55 @@ +let dbm; +let type; +let seed; +const fs = require('fs'); +const path = require('path'); + +/** + * We receive the dbmigrate dependency from dbmigrate initially. + * This enables us to not have to rely on NODE_PATH. + */ +exports.setup = function (options, seedLink) { + dbm = options.dbmigrate; + type = dbm.dataType; + seed = seedLink; +}; + +exports.up = function (db) { + const filePath = path.join( + __dirname, + 'sqls', + '20220311021020-AddSubOrganization-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) { + const filePath = path.join( + __dirname, + 'sqls', + '20220311021020-AddSubOrganization-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, +}; diff --git a/database/migrations/sqls/20220311021020-AddSubOrganization-down.sql b/database/migrations/sqls/20220311021020-AddSubOrganization-down.sql new file mode 100644 index 0000000..b98b010 --- /dev/null +++ b/database/migrations/sqls/20220311021020-AddSubOrganization-down.sql @@ -0,0 +1 @@ +ALTER TABLE earnings DROP COLUMN sub_organization; diff --git a/database/migrations/sqls/20220311021020-AddSubOrganization-up.sql b/database/migrations/sqls/20220311021020-AddSubOrganization-up.sql new file mode 100644 index 0000000..562abed --- /dev/null +++ b/database/migrations/sqls/20220311021020-AddSubOrganization-up.sql @@ -0,0 +1 @@ +ALTER TABLE earnings ADD sub_organization uuid NOT NULL;