await db.transaction(async (tx) => {
// Add project to DB
await tx.insert(projects).values({
// ...
});
// Add variables to DB
await tx.insert(variables).values(
repoVariables.data
.filter((v) => v.variable_type === 'env_var')
.map((v) => ({
// ...
})),
);
// Add variables history to DB
const projectVariables = await getProjectVariables(projectId);
console.log(projectVariables); // <-- empty array
await tx.insert(variablesHistory).values(
projectVariables.map((v) => ({
// ...
})),
);
});
await db.transaction(async (tx) => {
// Add project to DB
await tx.insert(projects).values({
// ...
});
// Add variables to DB
await tx.insert(variables).values(
repoVariables.data
.filter((v) => v.variable_type === 'env_var')
.map((v) => ({
// ...
})),
);
// Add variables history to DB
const projectVariables = await getProjectVariables(projectId);
console.log(projectVariables); // <-- empty array
await tx.insert(variablesHistory).values(
projectVariables.map((v) => ({
// ...
})),
);
});