Jump to content

Two site versions, one database


iipa
 Share

Recommended Posts

Hi everybody!

I have been reading about Multisite, but it kinda bugs me that every topic talks about having both admin and database same for multiple sites.

I have a project where customer tests it by adding content to the site, while I still need to do some changes here and there in code, maybe some in database. If something crashes for a while, customer can't keep testing, which is a bit problematic.

Is there any way that I could have two separate versions of one site ("production" and development) that share the same database, but are otherwise independent? Just the thought of having to migrate database every time I want to show client something new gives me anxiety 😁

Link to comment
Share on other sites

3 hours ago, iipa said:

Is there any way that I could have two separate versions of one site ("production" and development) that share the same database, but are otherwise independent?

What do you mean by "otherwise independent"? It is easy to have two pw instances connecting to one DB (just put the same in config.php), but that makes no sense in a production/dev environment. Adding a field to one site means you'll also have it in your other site. If your code does not reflect that (in BOTH instances), you'll get into trouble (php errors). And you don't want to have those DB changes on the live system instantly of course! Imagine you want to try adding a new "lorem ipsum" news entry... you'll instantly have it on your live system!

You have two options:

1) Duplicate your live website to the dev environment, make changes, test everything, push the changes back to live
--> this works only if you don't have any changes to the DB on your live system while you are developing/testing on your dev system

2) Migrations
https://processwire.com/blog/posts/introduction-migrations-module/
https://weekly.pw/issue/261/#new-module-rockmigrations (thx @teppo for listing it)

  • Like 1
Link to comment
Share on other sites

Hmm, that's a good point. There certainly are some risks that come with having the same database that I haven't considered. Thanks for pointing them out!

First solution doesn't work in this case, because client wants to test how things work with adding real content, so they probably wouldn't like the idea of things being wiped with every update.

The second option with migrations sounds cool though - might be just what I need!

  • Like 1
Link to comment
Share on other sites

Another (rather lo-fi) setup could be:

Use dev template files, as alternative templates. For testing out new content, you can leave pages unpublished and still preview them when logged in.

If your client (role) has permissions to switch templates with Tracy Debugger, there the template switcher panel you could use.

https://processwire.com/blog/posts/introducing-tracy-debugger/#template-path-panel

https://processwire-recipes.com/recipes/use-different-sets-of-template-files/

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

I had some issues with server provider and subdomain SSL certificate (I want all my sites use forced https), but after those were resolved, @dragan's solution works perfectly! So thanks again, now I'm able to use actual data also in testing phase, which helps in UI design.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...