Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
LamNz79 opened this issue Sep 12, 2024 · 1 comment · Fixed by #226

Comments

@LamNz79
Copy link

LamNz79 commented Sep 12, 2024

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:

  • Attempted to fix the issue by following the error message and adding some blank spaces in the migration file.
  • Even after these changes, the error persists.

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
Copy link
Member

benjie commented Sep 19, 2024

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\`
`,
      );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants