Does calling migration up return the actual migration execution result? #455
Unanswered
sametmasaci
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Looking through the document, I could not understand if there was a possible way of returning the execution of the migration(getting result from query interface function call). What I am expecting basically when I call umzug.up is the promise result which could be a new promise containing the query function call, resolving to something else or query result.
Here is the code that I need help about also attaching the same code
02-initial.txt
module.exports = {
up: async function (query, DataTypes) {
const promises = [];
const vals = [],
errs = [];
let dataFiles = await fs.readdirSync(path.join(__dirname, "./data"));
for (const jsonFile of dataFiles) {
let JSONData, data, tableName;
try {
JSONData = JSON.parse(
fs.readFileSync(path.join(__dirname, "./data", jsonFile))
);
tableName = Object.keys(JSONData)[0];
data = JSONData[tableName];
} catch (error) {}
if (tableName && data && data.length > 0) {
let [res, err] = await query.bulkInsert(tableName, data);
res && vals.push(res);
err && errs.push(err);
} else {
errs.push(
"TableName specified does not have any data. TableName: " +
tableName +
"data: " +
data
);
}
}
return new Promise(async (resolve, reject) => {
resolve({ vals, errs });
});
},
down: function (query, DataTypes) {},
};
Beta Was this translation helpful? Give feedback.
All reactions