add option to print sql instead of committing the changes itself

This commit is contained in:
Grant 2024-07-08 20:43:09 -06:00
parent bcbe093806
commit 5f57679bb3
1 changed files with 19 additions and 10 deletions

View File

@ -147,16 +147,25 @@ async function main() {
}, },
]; ];
for (const { name, hex } of palette) { if (process.argv?.[2] === "sql") {
log("Ensuring color", { name, hex }); log(`ALTER SEQUENCE "PaletteColor_id_seq" RESTART WITH 1;`);
await prisma.paletteColor.upsert({ for (const { name, hex } of palette) {
where: { hex }, log(
update: {}, `INSERT INTO "PaletteColor" (name, hex) VALUES ('${name}', '${hex}');`
create: { );
name, }
hex, } else {
}, for (const { name, hex } of palette) {
}); log("Ensuring color", { name, hex });
await prisma.paletteColor.upsert({
where: { hex },
update: {},
create: {
name,
hex,
},
});
}
} }
} }