graphile / migrate

Opinionated SQL-powered productive roll-forward migration tool for PostgreSQL.
MIT License
751 stars 58 forks source link

Error: Invalid migration './migrations/committed/000001.sql' after pulling committed SQL files #224

Closed LamNz79 closed 2 months ago

LamNz79 commented 2 months ago

I encountered an issue after pulling the committed SQL migration files from the repository. My friend pushed all of the SQL files, and when I tried to run the server using PostGraphile, the following error occurred during migration: Error: Invalid migration './migrations/committed/000001.sql': there should be two newlines after the headers section

Steps to Reproduce:

  1. Clone the repository.
  2. Pull the latest changes.
  3. Run the following commands:
    • npm start
    • npm run migrate migrate

What I Tried:

Question: How can I resolve this error with the migration file? Is there a specific way the SQL files should be structured that I am missing? Any guidance would be appreciated!

benjie commented 2 months ago

I've improved the error message in #226 to give you some solutions to the issue of git converting the line endings in your files:

      throw new Error(
        `Invalid migration '${fullPath}': it looks like the line endings have been corrupted - perhaps you have configured git to replace LF with CRLF? Here's a couple potential solutions:
Option 1: Add \`path/to/migrations/committed/*.sql -text\` to \`.gitattributes\` in your repository
Option 2: Globally reconfigure git to convert CRLF to LF on commit, but never convert LF back to CRLF: \`git config --global core.autocrlf input\`
`,
      );