From 250bace8a579ea96a5c39a99d19715edabb8ae9a Mon Sep 17 00:00:00 2001 From: Stefano Ricci <1219739+SteRiccio@users.noreply.github.com> Date: Thu, 15 Aug 2024 09:18:25 +0200 Subject: [PATCH] Record table: added column merged_into_record_uuid (#71) Co-authored-by: Stefano Ricci --- ...ter-table-record-add-column-merged-into.js | 51 +++++++++++++++++++ ...ble-record-add-column-merged-into-down.sql | 1 + ...table-record-add-column-merged-into-up.sql | 3 ++ 3 files changed, 55 insertions(+) create mode 100644 src/db/dbMigrator/migration/survey/migrations/20240813121444-alter-table-record-add-column-merged-into.js create mode 100644 src/db/dbMigrator/migration/survey/migrations/sqls/20240813121444-alter-table-record-add-column-merged-into-down.sql create mode 100644 src/db/dbMigrator/migration/survey/migrations/sqls/20240813121444-alter-table-record-add-column-merged-into-up.sql diff --git a/src/db/dbMigrator/migration/survey/migrations/20240813121444-alter-table-record-add-column-merged-into.js b/src/db/dbMigrator/migration/survey/migrations/20240813121444-alter-table-record-add-column-merged-into.js new file mode 100644 index 0000000..98ba064 --- /dev/null +++ b/src/db/dbMigrator/migration/survey/migrations/20240813121444-alter-table-record-add-column-merged-into.js @@ -0,0 +1,51 @@ +'use strict' + +var dbm +var type +var seed +var fs = require('fs') +var path = require('path') +var 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) { + dbm = options.dbmigrate + type = dbm.dataType + seed = seedLink + Promise = options.Promise +} + +exports.up = function (db) { + var filePath = path.join(__dirname, 'sqls', '20240813121444-alter-table-record-add-column-merged-into-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', '20240813121444-alter-table-record-add-column-merged-into-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/src/db/dbMigrator/migration/survey/migrations/sqls/20240813121444-alter-table-record-add-column-merged-into-down.sql b/src/db/dbMigrator/migration/survey/migrations/sqls/20240813121444-alter-table-record-add-column-merged-into-down.sql new file mode 100644 index 0000000..44f074e --- /dev/null +++ b/src/db/dbMigrator/migration/survey/migrations/sqls/20240813121444-alter-table-record-add-column-merged-into-down.sql @@ -0,0 +1 @@ +/* Replace with your SQL commands */ \ No newline at end of file diff --git a/src/db/dbMigrator/migration/survey/migrations/sqls/20240813121444-alter-table-record-add-column-merged-into-up.sql b/src/db/dbMigrator/migration/survey/migrations/sqls/20240813121444-alter-table-record-add-column-merged-into-up.sql new file mode 100644 index 0000000..da30ec3 --- /dev/null +++ b/src/db/dbMigrator/migration/survey/migrations/sqls/20240813121444-alter-table-record-add-column-merged-into-up.sql @@ -0,0 +1,3 @@ +ALTER TABLE record + ADD COLUMN IF NOT EXISTS merged_into_record_uuid uuid NULL; +