DEV Community

Discussion on: Postgresql on local and remote: how do you sync?

Collapse
 
buinauskas profile image
Evaldas Buinauskas • Edited

I wouldn't setup replication from local to production, better keep different db environments separate and don't let them know about each other.

It's best to treat your database (schema and static data) as a code and deploy your database as you deploy code. So the workflow would be as follows:

  • Prepare a database Git repository
  • Commit your schema and static data there
  • Deploy to production off your Git repository

Nothing really different from what you'd do with code. I've done many different and over-complicated database migrations and this is what I'd stick to, honestly.

There's a tool called Flyway that let's you run database migrations, I'd suggest to check it out, heard many good opinions about it, but never really used it.

Collapse
 
danroc profile image
Daniel da Rocha

Hi Evaldas!

I already have database migrations setup and running (Flask + SQLAlchemy + Alembic + Flask-Migrate).

My concern was mostly related to data, as I was feeding the database locally, and was wondering "what will happen when I put the admin online and want to feed it both locally AND remotely at times?".

Therefore what Rhymes described above sounds like a good solution...

Thanks!1
Best,
Daniel