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?
Related
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
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!
I'm trying to downgrade a heroku postgres db from standard to hobby basic. As I'm not fully using the web app currently but there is still some data in there that needs to be kept. How can I downgrade? (some downtime is fine).
Update: managed to setup and promote a new database based on the inststructions below, but i can't deprovision the old one.
heroku info shows:
Heroku's instructions for upgrading with pg:copy will also work for downgrading. Here's the summary:
Provision a new database
Enter maintenance mode to prevent database writes
Transfer data to the new database
Promote the new database
Exit maintenance mode
If your app isn't live (not being actively written to), you can skip the maintenance mode steps.
Once you've done that, you can deprovision your old database.
I want to understand how people are handing an update to a production app on the Parse.com platform. Here is the scenario that I am not sure about.
Create an called myApp_DEV. The app contains a database as well as associated cloud code.
Once testing is complete and ready for go-live I will clone this app into myApp_PRD (Production version). Cloning it will copy all the database as well as the cloud code.
So far so good.
Now 3 months down the line I want have added some functionality which includes adding some cloud code functions as well as adding some new columns to the tables in the db.
How do I update myApp_PRD with these new database structure. If i try to clone it from my DEV app it tells me the app all ready exists.
If I clone a new app (say myApp_PRD2) from DEV then all the data will be lost since the customer is all ready live.
Any ideas on how to handle this scenario?
Cloud code supports deploying to production and development environments.
You'll first need to link your production app to your existing cloud code. this can be done in the command line:
parse add production
When you're ready to release, it's a simple matter of:
parse deploy production
See the Parse Documentation for all the details.
As for the schema changes, I guess we just have to manually add all the new columns.
I have 3 instances of my rails app on heroku (test, stage and production). When I want to test an issue that is happening with real users' data, I would like to heroku db:pull --app production and then heroku db:push --app test. The problem is that at this point heroku rake db:migrate --app test throws an error because the columns the migration is trying to create have already been created.
My understanding is that heroku db:push pushes data into an existing database schema and rather than literally pushing the entire database (schema included). This means that the schema we are pushing to may be more advanced than the migrations table we are pushing since this migrations table will be missing migration records that have not run on the database we pulled from but have obviously run on the database we are pushing to.
My first question is, am I correct in my understanding of how this works? My second question is how do I fix this so that I can pull production data, stick it in testing and run migrations without receiving this error. Ideally, I would want to copy the production database and stick it in test and then migrate it fully since if I could do this I wouldn't have to worry about the existing schema on test. Is there a way to do this?
If not, is there a way to fake that migrations have already run by populating the new migrations table with records for each migration that has already run on my test database?
No, db:push pushes the local schema and data. You can push your local DB into an empty DB on Heorku, this is how I put sites live - when you run it you see it creating the schema then pushing the data in.
I work like this - Test environment on Heroku same code as live - ie. a branch of master (ie what's live and pushed to test). Pull DB from Live. Fix on my local system. Push to test and run migrations. Test release against DB on Heroku. When I'm happy merge test code into master and then deploy and run migrations. Rinse and Repeat for future bugs. The production DB should never have a more advanced schema version that test. You can always check this out by looking in the schema_migrations table - this is how Rails knows what migrations have run so far, so you can compare this to db/migrations files.