Skip to content

Commit

Permalink
migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
linusnorton committed Feb 23, 2024
1 parent e0b5886 commit ea3d3f9
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
53 changes: 53 additions & 0 deletions migrations/20240223184710-modify-journey-type.js
@@ -0,0 +1,53 @@
'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', '20240223184710-modify-journey-type-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', '20240223184710-modify-journey-type-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
};
@@ -0,0 +1 @@
/* Replace with your SQL commands */
2 changes: 2 additions & 0 deletions migrations/sqls/20240223184710-modify-journey-type-up.sql
@@ -0,0 +1,2 @@
/* RENAME location.type location.defaultJourneyType */
ALTER TABLE location CHANGE COLUMN type defaultJourneyType ENUM('journey', 'leisure') NOT NULL DEFAULT 'journey';

0 comments on commit ea3d3f9

Please sign in to comment.