-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add prisma seed for dev dump. Update scripts to run it automatically in docker-compose.
- Loading branch information
Showing
3 changed files
with
40 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
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,35 @@ | ||
import { PrismaClient } from '@prisma/client'; | ||
import * as fs from 'fs'; | ||
|
||
const prisma = new PrismaClient(); | ||
|
||
async function main() { | ||
const devDump = fs.readFileSync('./prisma/dev_dump.sql', 'utf-8'); | ||
|
||
for (const query of devDump.split('\n')) { | ||
if (query.trim() === '') { | ||
continue; | ||
} | ||
|
||
// ignore prisma migrations at it is already applied by migrate command | ||
// if (query.includes('_prisma_migrations')) { | ||
// continue; | ||
// } | ||
|
||
try { | ||
await prisma.$executeRawUnsafe(query); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
} | ||
} | ||
|
||
main() | ||
.then(async () => { | ||
await prisma.$disconnect(); | ||
}) | ||
.catch(async (e) => { | ||
console.error(e); | ||
await prisma.$disconnect(); | ||
process.exit(1); | ||
}); |