Simplified swap of SQLite for PostgreSQL on test self-hosted instance

Hi
There are quite a few posts about migrating from the default SQLite to PostgreSQL, several of which I’ve read through. Most of the posts seem to be about migrating data, credentials, workflows, etc on active or production instances of n8n. I’m however looking for a simple switch from SQLite to PostgreSQL and not really a full migration.
The self-hosted n8n instance was setup as a test environment, where I could learn n8n and test workflows. So not a production environment with any active workflows. I’m not to worried about losing the workflows, credentials and execution data when making the switch.
Obviously, one option is start up a new fresh n8n instance with PostgreSQL from the start. But, for various reasons, I don’t want to start fresh and want to retain the server setup and the rest of the n8n instance config.
Any suggestions how the switch can be made?

Information on your n8n setup

  • n8n version: 2.11.3
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker-compose
  • Operating system: Ubuntu
1 Like

Hi @OptimaBSC i think you just need to update your compose file, with DB_TYPE=postgresdb along with the required DB_POSTGRESDB_* environment variables on your n8n container and then run it via docker compose up -d so now the old data will be left and new data will be settled.

1 Like

Hi @Anshul_Namdev

Essentially, yes. The init-data.sh file tripped me up, though as I didn’t create that initially.

In the process I did remove the volumes and recreate when restarting docker. This wiped the slate clean, removing all workflows, credentials and data tables, as well as clearing the n8n self-hosted activation key. This wasn’t an issue for me, since this is a ‘sand box’ instance.

The instance is now running with PostgreSQL.

3 Likes

@OptimaBSC Glad it solved the issue! Although that was a risky approach but if that worked for you that is what matters!

Cheers! (Consider marking that as a solution if it helped)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.