Search code examples
phpwordpresslocaldevelopment-environment

How to edit website locally while live DB is still being edited


I'm relatively new to web development and I have some serious concerns about repairing/editing/fixing live site.

I use WordPress and its DB hold also configuration, so let's say that I need to do some work on website with e-shop. I will start website on my local with current version of DB from live website. But in few hours, when I'm done, I can't just overwrite live DB with my DB from local environment, because there are some new orders, posts etc.

How can we deal with this kinds of things?

Thanks everyone who will share his advice or experiences!


Solution

  • First youhave to make note of all the changes you are making in the files. You have to document it properly. Next there are actually three cases

    i) When changing the files alone

    if you are changing just the files then obviously no need to change the database only the files needs to be updated. First no need to hack the core wordpress files as everything can be done through "actions" and "filters" method. I mean by creating a plugin so your core files are safe. https://codex.wordpress.org/Writing_a_Plugin

    ii) When chaning the database alone

    if you are chaning the database instead of deleting the entire datase and reloading you can simply alter the tables using "ALTER" command http://dev.mysql.com/doc/refman/5.7/en/alter-table.html.

    iii) Changing both databse and files.

    Follow (i) and (ii)