Yes, you can accomplish this by using our export / import feature.
In your local setup while running SQLite use the following command to make a backup of your data.
Here I have a project with simple post collection type.
Currently my project is using SQLite.
I am going to use the following command to export my data.
yarn strapi export --no-encrypt -f backup
Now update your ./config/database.js
file to point to a postgresql instance and update accordingly.
Install pg
vith yarn add pg
to add postgres support. pg - npm
module.exports = ({ env }) => ({
connection: {
client: 'postgres',
connection: {
host: env('DATABASE_HOST', '127.0.0.1'),
port: env.int('DATABASE_PORT', 5432),
database: env('DATABASE_NAME', 'strapi'),
user: env('DATABASE_USERNAME', 'strapi'),
password: env('DATABASE_PASSWORD', 'strapi'),
schema: env('DATABASE_SCHEMA', 'public'), // Not required
ssl: env.bool('DATABASE_SSL', false) && {
rejectUnauthorized: env.bool('DATABASE_SSL_SELF', false), // For self-signed certificates
},
},
debug: false,
},
});
Once you make these changes, run the following command.
yarn build && yarn develop
Because you are now pointing to a fresh postgres db you will need to create a new admin user.
Once logged in, you will see that you don’t have any data.
Now let’s restore our data with the import
command from our recently created backup
file.
You can run the following command.
yarn strapi import -f backup.tar.gz
After restarting your Strapi App, you should now be able to see your data.
Now we can double check out postgres db to confirm the migration.
You can now see that I am now using my postgres db with my previous data.
Hope this helps.