Skip to content

Commit de0aaa4

Browse files
authored
feat!: remove 'prisma setup-db-for-litestream' and add pragmas getters (#565)
1 parent ddb7108 commit de0aaa4

File tree

4 files changed

+8
-35
lines changed

4 files changed

+8
-35
lines changed

packages/shared-lib/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export { mailTemplates } from './mail.js';
44
export { parseCommandLineArgs } from './parseCommandLineArgs.js';
55
export { shuffle } from './shuffle.js';
66
export { sleep } from './sleep.js';
7+
export { getConnectionLevelSqlitePragmas, getPersistentSqlitePragmas } from './sqlite.js';
78
export { zenkakuAlphanumericalsToHankaku } from './zenkaku.js';
89

910
export type { RetryOptions } from './error.js';

packages/shared-lib/src/sqlite.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export function getConnectionLevelSqlitePragmas(): string {
2+
return 'PRAGMA busy_timeout = 5000; PRAGMA synchronous = NORMAL; PRAGMA wal_autocheckpoint = 0;';
3+
}
4+
5+
export function getPersistentSqlitePragmas(): string {
6+
return 'PRAGMA journal_mode = WAL;';
7+
}

packages/wb/src/commands/prisma.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export const prismaCommand: CommandModule = {
2424
.command(deployCommand)
2525
.command(deployForceCommand)
2626
.command(listBackupsCommand)
27-
.command(setUpDBForLitestreamCommand)
2827
.command(migrateCommand)
2928
.command(migrateDevCommand)
3029
.command(resetCommand)
@@ -190,18 +189,6 @@ const seedCommand: CommandModule<unknown, InferredOptionTypes<typeof seedBuilder
190189
},
191190
};
192191

193-
const setUpDBForLitestreamCommand: CommandModule<unknown, InferredOptionTypes<typeof builder>> = {
194-
command: 'setup-db-for-litestream',
195-
describe: 'Setup DB for Litestream',
196-
builder,
197-
async handler(argv) {
198-
const allProjects = await findPrismaProjects(argv);
199-
for (const project of prepareForRunningCommand('prisma setup-db-for-litestream', allProjects)) {
200-
await runWithSpawn(prismaScripts.setUpDBForLitestream(project), project, argv);
201-
}
202-
},
203-
};
204-
205192
const studioBuilder = {
206193
...builder,
207194
'db-url-or-path': {

packages/wb/src/scripts/prismaScripts.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import fs from 'node:fs';
22
import path from 'node:path';
33

44
import type { Project } from '../project.js';
5-
import { runtimeWithArgs } from '../utils/runtime.js';
65

76
/**
87
* A collection of scripts for executing Prisma commands.
@@ -63,27 +62,6 @@ class PrismaScripts {
6362
return `if [ -e "prisma/seeds.ts" ]; then BUN build-ts run prisma/seeds.ts; fi`;
6463
}
6564

66-
setUpDBForLitestream(_: Project): string {
67-
// cf. https://litestream.io/tips/
68-
return `${runtimeWithArgs} -e '
69-
const { PrismaClient } = require("@prisma/client");
70-
const prisma = new PrismaClient();
71-
(async () => {
72-
try {
73-
await prisma.$queryRawUnsafe("PRAGMA busy_timeout = 5000");
74-
await prisma.$queryRawUnsafe("PRAGMA journal_mode = WAL");
75-
await prisma.$queryRawUnsafe("PRAGMA synchronous = NORMAL");
76-
await prisma.$queryRawUnsafe("PRAGMA wal_autocheckpoint = 0");
77-
} catch (error) {
78-
console.error("Failed due to:", error);
79-
process.exit(1);
80-
} finally {
81-
await prisma.$disconnect();
82-
}
83-
})();
84-
'`;
85-
}
86-
8765
studio(project: Project, dbUrlOrPath?: string, additionalOptions = ''): string {
8866
const FILE_SCHEMA = 'file:';
8967
let prefix = '';

0 commit comments

Comments
 (0)