gabrielmoreira / craftman

Craft CMS Manager
MIT License
124 stars 11 forks source link

Syncing database with heroku #4

Open robinsandborg opened 8 years ago

robinsandborg commented 8 years ago

When following the instructions in the readme, the heroku app seems to start up with a clean database. Are there any tools to sync the database between the local and heroku environments?

gabrielmoreira commented 8 years ago

@robinsandborg, sorry about the delay to help you, I was on vacation.

Maybe there is some plugin to import / export, but might be incompatible with other installed plugins. I've tried some with partial success, but generally have limitations or problems. https://straightupcraft.com/craft-plugins

I can also suggest to you, a similar way I like to work:

  1. You can back up your site database craftman mysql:backup, open the .sql file within the backup and import into mysql in heroku. You need only take care to edit the .sql file and replace the localhost or 127.0.0.1 for the domain that you will use in heroku. In some cases you want to change http to https in some urls within the .sql file.
  2. Create serious content only on Heroku, and use the local environment just to test the fields and templates.
  3. When you are satisfied with the stage of local development, create the fields manually in heroku environment, or use a plugin to import fields (Sometimes i use https://straightupcraft.com/craft-plugins/field-manager).
  4. Make a backup of your Craft on heroku (settings page > download backup), and import this backup to your local database. To help in the import process remember to change the .sql file and replace the domain by 127.0.0.1, or https to http again. To import a backup on your local environment, craftman has craftman mysql:restore <BACKUP_FILE_NAME>, and along with it, there is a way for you to create a script / hook to make these replacements automatically each time you import a backup with craftman: See a function mysql_restore_hook() here https://github.com/gabrielmoreira/craftman#advanced