migrate Strapi project from sqlite to postgres - strapi

I've got a local strapi set up with sqlite. I didn't think ahead, sadly that I would need use postgres to deploy to Heroku later.
After struggling to deploy with the project using sqlite, I decided to create a new project using postgres and successfully deployed it to Heroku. Now, in the local project, I've already setup content types, pages and everything. I was wondering, instead of having to recreate what I have done locally, how do I copy what I've done to the new project on Heroku including the database (sqlite --> postgres).
Has anyone done this before or maybe could point me to the right direction?
thank you in advance!

According to this:
https://github.com/strapi/strapi/issues/205#issuecomment-490813115
Database migration (content types and relations) is no longer an issue, but moving existing data entries from one database to another is.
To change database provider, I suppose you just need to edit config/environments/**/database.json according to Postgres setup.

Faced same issue, my solution is to use new project to generate a core for PostgreSQL and then run your existing code base on freshly created PostgreSQL:
npx create-strapi-app my-project and then choose custom -> PostgreSQL (Link)
When manually create a collections that are exists in SQLite, without fields
Run your old codebase with new database config which point on a PostgreSQL (that will create fields that you have in your data models)
Require a little bit of manual work, but works for me. Good luck!

Related

Baseline existing database

Im looking at Sqitch and so far it seems like a great tool, however I have an existing project that I want to use it with, Is there a way to create a baseline?
For example, I take a backup of my schema then add it to the deploy script, I then want to run a command that will not run the this script on the database as it already exists, but would apply everything after this point?
I need the full base schema in there so that we can re-deploy the whole schema if required
You can use the --log-only option of sqitch deploy command
From the docs: https://sqitch.org/docs/manual/sqitch-deploy/
--log-only
Log the changes as if they were deployed, but without actually running the deploy scripts. Useful for an existing database that is being converted to Sqitch, and you need to log changes as deployed because they have been deployed by other means in the past.

Can I get rid of MySql container completly

With DDEV, I'm developing with Laravel a project and I use Sqlite for local so I don't really need a proper Database available.
Is there any way to take out of formula the db container completely?
My final goal is to save battery usage.
Of course. Set omit_containers: [db,dba] in either your project or global configuration. ddev config --omit-containers=db,dba
Docs at https://ddev.readthedocs.io/en/stable/users/extend/config_yaml/

Data does not persist when dyno is restarted in Heroku?

I have deployed Strapi headless CMS on Heroku free tier and tried to use it both with MongoDB and Postgres databases, whenever I restart the dyno e.g. during deployment - all the data created thus far is not persisted?
I tried rebuilding Strapi locally and I cannot reproduce the behaviour.
I am using free tier for hosting of Strapi as well as free tier of Heroku Postgres.
Most likely you created your project with --quickstart which is not Postgres, it is SQLite. Can you please check your config/environments/*/database.json files and ensure you have PostgreSQL setup?
All model configs are stored in files meaning you will not be able to create, edit, or delete new models, fields, components while using Heroku. All data (content) is saved to the database.
https://strapi.io/documentation/3.0.0-beta.x/guides/deployment.html#heroku

Strapi : What is the Content and API migration strategy

Strapi is a powerful tool, but I am unable to find any documentation/instructions which explain about the best practices/strategy to migrate contents from one environment to another, for example Dev to staging to production ?
If you got a lot of content and recreate all the content on each environment is not viable.
Please guide, how to move API and DB (mongo) stuff.
If there is only manual workaround for now, we should document it so that can be used for now.
For now there is no other way than manually import/export your database:
Github issue: Import / export data

Migrating changes in table structure with Sinatra/Ruby/Heroku

I have made my app with Sinatra/Ruby and deployed with Heroku. I made some extra columns to my database and manually dropped the table and put the new one up with Postgres so it works with my local version but not the Heroku one. I have already deployed my app with Heroku before this change and struggle finding a way to update the new table structure to the deployed version with terminal and heroku commands. Could someone help me with this?

Resources