|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +var dbm; |
| 4 | +var type; |
| 5 | +var seed; |
| 6 | +var fs = require('fs'); |
| 7 | +var path = require('path'); |
| 8 | +var Promise; |
| 9 | + |
| 10 | +/** |
| 11 | + * We receive the dbmigrate dependency from dbmigrate initially. |
| 12 | + * This enables us to not have to rely on NODE_PATH. |
| 13 | + */ |
| 14 | +exports.setup = function(options, seedLink) { |
| 15 | + dbm = options.dbmigrate; |
| 16 | + type = dbm.dataType; |
| 17 | + seed = seedLink; |
| 18 | + Promise = options.Promise; |
| 19 | +}; |
| 20 | + |
| 21 | +exports.up = function(db) { |
| 22 | + const fileName = |
| 23 | + process.env.NODE_ENV === "test" |
| 24 | + ? "20250114232200-update-etpl-up-TEST.sql" |
| 25 | + : "20250114232200-update-etpl-up.sql"; |
| 26 | + var filePath = path.join(__dirname, 'sqls', fileName); |
| 27 | + return new Promise( function( resolve, reject ) { |
| 28 | + fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ |
| 29 | + if (err) return reject(err); |
| 30 | + console.log('received data: ' + data); |
| 31 | + |
| 32 | + resolve(data); |
| 33 | + }); |
| 34 | + }) |
| 35 | + .then(function(data) { |
| 36 | + return db.runSql(data); |
| 37 | + }); |
| 38 | +}; |
| 39 | + |
| 40 | +exports.down = function(db) { |
| 41 | + const fileName = |
| 42 | + process.env.NODE_ENV === "test" |
| 43 | + ? "20250114232200-update-etpl-down-TEST.sql" |
| 44 | + : "20250114232200-update-etpl-down.sql"; |
| 45 | + var filePath = path.join(__dirname, 'sqls', fileName); |
| 46 | + return new Promise( function( resolve, reject ) { |
| 47 | + fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ |
| 48 | + if (err) return reject(err); |
| 49 | + console.log('received data: ' + data); |
| 50 | + |
| 51 | + resolve(data); |
| 52 | + }); |
| 53 | + }) |
| 54 | + .then(function(data) { |
| 55 | + return db.runSql(data); |
| 56 | + }); |
| 57 | +}; |
| 58 | + |
| 59 | +exports._meta = { |
| 60 | + "version": 1 |
| 61 | +}; |
0 commit comments