N8n initialization issue after database migration to cloud SQL

Hey everyone,

I’m having trouble with my n8n setup after moving it to a cloud environment. Here’s what I did:

  1. Exported data from my old Postgres database
  2. Imported it into a new cloud SQL instance
  3. Set up n8n 1.51.2 in a Docker container on GCP Cloud Run

The connection to the new database seems fine, but when I try to start n8n, I get this error:

Error: There was an error running database migrations
QueryFailedError: relation "migrations" already exists

I’m confused because the migrations table is already there. Why is n8n trying to create it again? Does anyone know what triggers these migrations?

I thought it would just start up normally without messing with migrations.

Thanks for any help!

I’ve been through a similar migration headache with n8n before. One thing that worked for me was clearing out the migration history in the database before starting n8n in the new environment. You can do this by truncating the ‘migrations’ table:

TRUNCATE TABLE migrations;

This essentially tells n8n to start fresh with migrations. Just be careful and make sure you have a solid backup first.

Another approach is to check if your n8n version in the new setup matches exactly with what you had before. Even minor version differences can cause migration hiccups.

If all else fails, you might need to dig into the n8n migration files and manually adjust things. It’s a bit of a pain, but sometimes necessary when moving between environments. Good luck with the setup!

hey mandy, sounds like a tricky situation! have u tried dropping the migrations table before importing? sometimes n8n gets confused when theres existing migration data. might be worth a shot to start fresh. also double check ur db connection string, make sure its pointing to the right place. good luck!

I encountered a similar issue when migrating my n8n setup. The problem likely stems from mismatches between your previous environment and the new one, particularly regarding version configurations. One approach is to ensure your Docker image version matches exactly with your previous n8n version. If that does not work, consider temporarily disabling migrations by setting the N8N_SKIP_MIGRATIONS environment variable to true. Alternatively, you might need to manually adjust the migrations table to align with the expected state. Always remember to back up your data before making any changes. If the issue persists, additional insights on the n8n community forum or GitHub issues could provide further assistance.