Skip to content

Commit

Permalink
fix: don't seed production
Browse files Browse the repository at this point in the history
  • Loading branch information
Isak-Kallini committed Dec 8, 2024
1 parent b2391cb commit c32dc82
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/database/seed/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,22 @@ import {
models,
POLICYS,
} from "./data";
import { exec } from "child_process";
import util from "util";

const main = async () => {
try {
const ipSockets = await util.promisify(exec)(
"lsof -i | grep -E 'ssh.*:postgresq?l? \\(LISTEN\\)'",
);
if (ipSockets.stdout.split("\n").length === 3) {
console.log(
"\x1b[41mPostgres ssh tunnel detected, might be production database. Cancelled seeding\x1b[0m",
);
process.exit(1);
}
} catch (ignored) {}

Check failure on line 30 in src/database/seed/main.ts

View workflow job for this annotation

GitHub Actions / build

'ignored' is defined but never used

Check failure on line 30 in src/database/seed/main.ts

View workflow job for this annotation

GitHub Actions / build

Empty block statement

const seed = await createSeedClient({
connect: true,
models,
Expand Down

0 comments on commit c32dc82

Please sign in to comment.