How to apply code changes without wiping the database? (Docker)

How can I have a flex image pull the repo and rebuild, without wiping the database in the process?

I’ve tried binding the databasevolume to a local path, which mostly works - when I do a docker-compose down -v, the database isn’t erased, which is half of the goal

But when I try to compose it back up, it fails during setup because the table already exists. (CREATE TABLE ccda_field_mapping fails)

I can’t find where this comes from, or I’d try to add a conditional there. There are two instances of CREATE TABLE ccda_field_mapping in the source, but one checks if it exists first, and the other drops the table first, so I suppose whatever’s causing this is neither of those.

Alternatively, if there’s a docker command to just pull the git repo and rebuild without dropping the database, that would work too. The given command wipes the database:
docker exec -i $(docker ps | grep _openemr | cut -f 1 -d " ") sh -c '/root/devtools dev-reset-install'
And I’m unsure if it actually pulls the repo down again. The non-reinstall reset command also wipes the db, and both throw errors if not on easy-development. Though they do seem to work, it just has to be composed down and back up again (and, of course, wipes the db)

I have used development-easy, which works, and I am now trying to update an existing installation to the new changes

I could always take a snapshot, export it, reinstall everything, then import it - but I figure there must be an easier way to do this? And it sounds very risky; someone could easily forget to make a snapshot before updating

Hi @Dimencia ,

Note the development docker environments (such as easy, insane, etc.) are not meant for production and are meant for development (for example, xdebug us turned on, which would be considered a potential security issue). Although could definitely use (as maybe you are doing) as a place to test/debug stuff before pushing to your production server and instance.

While doing development work, if I need to maintain the “data” (sql database, stuff in sites directory, and couchdb (if using couchdb)), then I create a snapshot, which can then export from the docker as a capsule. This capsule can then be imported and snapshot restored on a brand new easy docker environment (ie. would essentially bring the “data” into use by new code changes).

openemr/ at master · openemr/openemr · GitHub
openemr/ at master · openemr/openemr · GitHub

btw, here’s a command that makes doing the devtools commands way easier:
openemr-devops/utilities/openemr-cmd at master · openemr/openemr-devops · GitHub