@@ -249,7 +249,7 @@ async function runSqldef(binaryPath, config) {
249249 // Return combined output for successful runs
250250 return output + stderr;
251251}
252- async function createComment(body) {
252+ async function createComment(body, command, schemaFile ) {
253253 const context = github.context;
254254 if (context.eventName !== "pull_request") {
255255 core.warning("Not a pull request event, skipping comment");
@@ -266,11 +266,19 @@ async function createComment(body) {
266266 repo: context.repo.repo,
267267 issue_number: context.payload.pull_request.number,
268268 });
269- const title = "SQLDef Migration Preview";
270- const previousComment = comments.find((comment) => comment.user?.type === "Bot" && comment.body?.includes(title));
269+ // Create a unique ID for this command/schema combination
270+ const commentId = `${command}-${schemaFile}`;
271+ const htmlCommentId = `<!-- sqldef-preview-action-id: ${commentId} -->`;
272+ // Find previous comment by searching for the HTML comment ID
273+ const previousComment = comments.find((comment) => comment.user?.type === "Bot" && comment.body?.includes(htmlCommentId));
274+ const title = `SQLDef Migration Preview (${command})`;
275+ const subtitle = `Schema file: \`${schemaFile}\``;
271276 const commentBody = `
277+ ${htmlCommentId}
272278## ${title}
273279
280+ ${subtitle}
281+
274282~~~sql
275283${body}
276284~~~
@@ -367,14 +375,14 @@ async function run() {
367375 core.info(output);
368376 // Only create comment for actual PR events
369377 if (context.eventName === "pull_request" && !baselineSchemaFile) {
370- await createComment(output);
378+ await createComment(output, command, schemaFile );
371379 }
372380 }
373381 else {
374382 core.info("No schema changes detected");
375383 // Only create comment for actual PR events
376384 if (context.eventName === "pull_request" && !baselineSchemaFile) {
377- await createComment("No schema changes detected.");
385+ await createComment("No schema changes detected.", command, schemaFile );
378386 }
379387 }
380388 if (!baselineSchemaFile && actualBaselineFile && actualBaselineFile !== "" && fs.existsSync(actualBaselineFile)) {
0 commit comments