Multiple Databases

System Information
  • Strapi Version: 4.6.0
  • Operating System: MacOS
  • Database:
  • Node Version: 18.12.1
  • NPM Version: 8.19.2
  • Yarn Version: 1.22.19

I want to modify the file config/database.js to use multiple databases. I need to use sqlite for local and MySQL for dev and prod. Is there any way to do this? I’m using Strapi 4.6.0

This is what I have in my config/database.js:

module.exports = ({ env }) => ({
  connection: {
    client: 'mysql',
    connection: {
      host: env('DATABASE_HOST'),
      port: env.int('DATABASE_PORT'),
      database: env('DATABASE_NAME'),
      user: env('DATABASE_USERNAME'),
      password: env('DATABASE_PASSWORD'),
      ssl: env.bool('DATABASE_SSL', false),
    },
  },
});

Hello there :birthday:
It’s covered in the documentation

Configurations can be created with the following naming and structure conventions:
./config/env/{environment}/{filename}.
This is useful when you need specific static configurations
for specific environments and using environment variables is not the best solution.