Skip to content

Instantly share code, notes, and snippets.

@suhjohn
suhjohn / migrate-down.ts
Last active September 8, 2023 13:22
Prisma migrate down
import { exec } from 'child_process';
import { log } from 'console';
import * as fs from 'fs';
import * as path from 'path';
import { Client } from 'pg'; // Assuming you have 'pg' npm package installed.
import * as util from 'util';
const execPromise = util.promisify(exec);
@suhjohn
suhjohn / generate-migration.ts
Created July 16, 2023 02:11
Prisma generate new migration with down migration
/**
* generate-migration.ts
*
* This script generates a migration that moves the down.sql file to the latest migration folder.
* Use:
* ts-node generate-migration.ts <MIGRATION_NAME>
* yarn migrate:generate <MIGRATION_NAME>
*/
import { execSync } from 'child_process';
import { log } from 'console';