Skip to content

Commit cd260ea

Browse files
committed
Make it clearer which bit we need to be careful with
1 parent 918888b commit cd260ea

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/commands/uncommit.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,20 @@ export async function _uncommit(parsedSettings: ParsedSettings): Promise<void> {
4040
// Restore current.sql from migration
4141
const lastMigrationFilepath = lastMigration.fullPath;
4242
const contents = await fsp.readFile(lastMigrationFilepath, "utf8");
43-
const { headers, body } = parseMigrationText(lastMigrationFilepath, contents);
43+
const { headers, body: committedBody } = parseMigrationText(
44+
lastMigrationFilepath,
45+
contents,
46+
);
4447

4548
// Replace included migrations with their `--!include` equivalent
46-
const decompiledBody = body.replace(
49+
const body = committedBody.replace(
4750
/^--! Included (?<filename>\S+)$[\s\S]*?^--! EndIncluded \k<filename>$/gm,
4851
(_, filename) => `--!include ${filename}`,
4952
);
5053

5154
// Drop Hash, Previous and AllowInvalidHash from headers; then write out
5255
const { Hash, Previous, AllowInvalidHash, ...otherHeaders } = headers;
53-
const completeBody = serializeMigration(decompiledBody, otherHeaders);
56+
const completeBody = serializeMigration(body, otherHeaders);
5457
await writeCurrentMigration(parsedSettings, currentLocation, completeBody);
5558

5659
// Delete the migration from committed and from the DB

0 commit comments

Comments
 (0)