Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat: added slugify migration file creater name and additional check to ensure migration files are not editied in PR
=506e86d666d5
diff --git a/.github/workflows/check-migration-file-edited.yml b/.github/workflows/check-migration-file-edited.ymlnew file mode 100644index 0000000000..b12f8578de--- /dev/null+++ b/.github/workflows/check-migration-file-edited.yml@@ -0,0 +1,25 @@+name: Check migration file edited++on:+ pull_request:+ types: [opened, synchronize]+ paths:+ - 'backend/src/db/migrations/**'++jobs:+ rename:+ runs-on: ubuntu-latest+ steps:+ - name: Check out repository+ uses: actions/checkout@v4+ with:+ fetch-depth: 0++ - name: Check any migration files are modified, renamed or duplicated.+ run: |+ git diff --name-status HEAD^ HEAD backend/src/db/migrations | grep '^M\|^R\|^C' || true | cut -f2 | xargs -r -n1 basename > edited_files.txt+ if [ -s edited_files.txt ]; then+ echo "Migration files has been edited"+ cat edited_files.txt+ exit 1+ fidiff --git a/.github/workflows/update-be-new-migration-latest-timestamp.yml b/.github/workflows/update-be-new-migration-latest-timestamp.ymlindex 684c786541..a98a8ca860 100644--- a/.github/workflows/update-be-new-migration-latest-timestamp.yml+++ b/.github/workflows/update-be-new-migration-latest-timestamp.yml@@ -19,18 +19,16 @@ jobs:- name: Get list of newly added files in migration folderrun: |- git diff --name-status HEAD^ HEAD backend/src/db/migrations | grep '^A' | cut -f2 | xargs -n1 basename > added_files.txt+ git diff --name-status HEAD^ HEAD backend/src/db/migrations | grep '^A' || true | cut -f2 | xargs -r -n1 basename > added_files.txtif [ ! -s added_files.txt ]; thenecho "No new files added. Skipping"- echo "SKIP_RENAME=true" >> $GITHUB_ENV+ exit 0fi- name: Script to rename migrations- if: env.SKIP_RENAME != 'true'run: python .github/resources/rename_migration_files.py- name: Commit and push changes- if: env.SKIP_RENAME != 'true'run: |git config user.name github-actionsgit config user.email [email protected]diff --git a/backend/scripts/create-migration.ts b/backend/scripts/create-migration.tsindex 59040a37ac..34f4aca419 100644--- a/backend/scripts/create-migration.ts+++ b/backend/scripts/create-migration.ts@@ -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}`,