Merge pull request #2039 from akhilmhdh/feat/migration-file-checks

feat: added slugify migration file creater name and additional check to ensure migration files are not editied in PR
This commit is contained in:
Maidul Islam
2024-07-01 21:01:47 -04:00
committed by GitHub
3 changed files with 29 additions and 5 deletions
+2 -1
View File
@@ -2,13 +2,14 @@
import { execSync } from "child_process";
import path from "path";
import promptSync from "prompt-sync";
import slugify from "@sindresorhus/slugify"
const prompt = promptSync({ sigint: true });
const migrationName = prompt("Enter name for migration: ");
// Remove spaces from migration name and replace with hyphens
const formattedMigrationName = migrationName.replace(/\s+/g, "-");
const formattedMigrationName = slugify(migrationName);
execSync(
`npx knex migrate:make --knexfile ${path.join(__dirname, "../src/db/knexfile.ts")} -x ts ${formattedMigrationName}`,