-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add data migration for Summon Mayfly Swarm (#95)
- Loading branch information
Showing
4 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/excavator-web/prisma/migrations/20240624083527_fix_mayfly_zone/data-migration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { PrismaClient } from "@prisma/client"; | ||
|
||
import { hashData } from "../../../etl.js"; | ||
|
||
const prisma = new PrismaClient(); | ||
|
||
async function main() { | ||
await prisma.$transaction(async (tx) => { | ||
const data = await tx.spadingData.findMany({ | ||
where: { | ||
project: "Summon Mayfly Swarm", | ||
data: { | ||
path: ["area"], | ||
equals: "Conspiracy Island", | ||
}, | ||
}, | ||
}); | ||
|
||
for (const datum of data) { | ||
await tx.spadingData.update({ | ||
where: { id: datum.id }, | ||
data: { | ||
dataHash: hashData( | ||
datum.data as unknown as Record<string, string | number | boolean>, | ||
), | ||
}, | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
main() | ||
.catch(async (e) => { | ||
console.error(e); | ||
process.exit(1); | ||
}) | ||
.finally(async () => await prisma.$disconnect()); |
11 changes: 11 additions & 0 deletions
11
packages/excavator-web/prisma/migrations/20240624083527_fix_mayfly_zone/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- Update the area of Mayfly data to be the zone instead of the location. This was only done for Conspiracy Island locations. | ||
UPDATE "SpadingData" | ||
SET | ||
"data" = jsonb_set (data, '{area}', '"Conspiracy Island"') | ||
WHERE | ||
"project" = 'Summon Mayfly Swarm' | ||
AND "data"->>'area' IN ( | ||
'The Secret Government Laboratory', | ||
'The Mansion of Dr. Weirdeaux', | ||
'The Deep Dark Jungle' | ||
); |