feat: persistent lootbox states, update command now runs db migrations

This commit is contained in:
syntaxbullet
2025-12-18 17:02:21 +01:00
parent 83cd33e439
commit 7cf8d68d39
4 changed files with 79 additions and 38 deletions

View File

@@ -76,9 +76,27 @@ export const update = createCommand({
const { stdout } = await execAsync(`git reset --hard origin/${branch}`);
// Run DB Migrations
await confirmation.editReply({
embeds: [createWarningEmbed("Updating database schema...", "Running Migrations")],
components: []
});
let migrationOutput = "";
try {
const { stdout: dbOut } = await execAsync("bun run db:push:local");
migrationOutput = dbOut;
} catch (dbErr: any) {
migrationOutput = `Migration Failed: ${dbErr.message}`;
console.error("Migration Error:", dbErr);
// We continue with restart even if migration fails?
// Probably safer to try, or should we abort?
// For now, let's log it and proceed, as code might depend on it but maybe it was a no-op partial fail.
}
await interaction.followUp({
flags: MessageFlags.Ephemeral,
embeds: [createSuccessEmbed(`Git Reset Output:\n\`\`\`\n${stdout}\n\`\`\`\nRestarting process...`, "Update Successful")]
embeds: [createSuccessEmbed(`Git Reset Output:\n\`\`\`\n${stdout}\n\`\`\`\nDB Migration Output:\n\`\`\`\n${migrationOutput}\n\`\`\`\nRestarting process...`, "Update Successful")]
});
// Write context for post-restart notification