Clone (update latest changes) in new remote DB in DB Manager on new remote Docker

In theory, if I ‘Save Database Structure and Data’ from the Wappler toolbar, then go to the live target, and rebuild - it should capture that db structure and data right? From within Wappler?

The issue I’m having - I can login locally to the app via the Docker local server. But I cannot login with the remote, I keep getting the above error.

You already create a JSON for tables and their columns in the ‘meta’ options in Connections php file. Could you not iterate through that to create the same structure?

It would need to identify which are views and then which views depend on other views etc. Also which may have FK dependencies on other tables so they were created in order.

Other than exporting/importing a dump file through the db engine internal tools? That is what I would do.

This is kind of a very specific scenario that shouldn’t happen too much, right? Or at least it is the first topic I see about it.

I don’t see personally much added value in adding this to Wappler and will probably make people break their db more than fixing it and it will render the migration files useless.

I mean this is fixable in its current state. Export a dump and import a dump. It involves two terminal commands only.

1 Like

Cloning the empty structure, would be a tremendous start. For me it would be as good (or possibly better) as being able to copy the data too.

I’ve looked in the db_init for the local, and it just has the generic .sql files for the docker container (cars.sql, countries.sql etc.) there is nothing in there relating to my DB that I’be built with the DB Manager.

To backup the full db structure and data from the local docker dev database and reapply it on the live remote docker follow the following steps:

WARNING: this should be only performed on empty new Live target!! Otherwise you will loose your existing live database.

  1. Switch to your local docker target and click on “Save Database Data and Structure” icon

image

  1. Open your project folder in Finden/Windows Explorer and copy the file db_save.sql from the Local Docker folder db_init to your Live Docker target folder db_init - make sure there are no other sql files in it!

image

  1. Switch to the Live target (1), shudown the Services if running (2) and then launch them (3) - this will build the database with the backup data and structure you saved from the local dev

image

6 Likes

I think this would be very useful.

1 Like

I can see this being hugeley beneficial @George - this would allow for the entire db structure to be setup on dev, work with it - then when ready, simply clone the db structure to staging and production - as it’s typical to work with different data in those environments, so cloning the data isn’t so much of a requirement for me.

You guys know that you can do that already right? No need to wait for Wappler to implement it.

For mysql you can just use mysqldump command or the UI of the workbench app.

https://dev.mysql.com/doc/workbench/en/wb-admin-export-import-management.html

And for PostgreSQL you can use pg_dump command or a UI like pgAdmin.

Or use the docker method I mentioned above:

1 Like

3 posts were split to a new topic: Improve Database Manager with existing schema changes synchronization

@George when I go to production I’ll most likely move outside of the MySql provided within my Docker Container to a managed DB.

I was wondering if the db_init/db_save.sql would be a way I can clone the schema to a new remote DB that’s not within Wappler? would it work the same way?

Yes but you should just use the database manager and apply the changes on the new target. That is the official way.

The db_init way is for docker only and is just for full backups and as a last resort.

This is also the method I use. I found it as a solution myself in this bug thread. It’s not ideal, but it works. I think for new users it’s really frustrating if this doesn’t work when you want to deploy to live, so better instructions for this in the documentation instead of on the forum would be welcome I suppose. Maybe a copy db structure and data to/from target-functionality would be a good (temporary) solution too.

Unfortunately, if you remember some of the change history is deleted so if I take the official approach it won’t recreate the entire db the same.

But with Mac where is the db_save.sql file?

Hi George.
your suggestion is unfortunately impossible for me to implement
Maybe because I don’t use Windows, but MacOS, I can save the database correctly (I receive confirmation from the program) but then I can’t understand where and how to view the .wappler directory
Or maybe I’m the one who didn’t understand how to do it?
Setting up a site in NodeJS with Wappler and Docker on Hetzner is fantastic and really fast (I have already set up 3 projects) but if I can’t import the data contained in the old databases, I get stuck.

the .wappler folder is hidden. You need to enable hidden files and folders in Finder or in Wappler File Manager - right click in Wapper File Manager and select “Show Hidden” to see it.

1 Like

Thank You

Hello Teodor
I tried but it doesn’t work for me
1- in Local mode I export the database (db_save.sql) from wappler
Schermata 2021-04-05 alle 18.45.19
2- load the file in the PC and modify the database by adding tables and contents
3- I create new sql file and name it db_save.sql
4- I substitute the one exported by Wappler
5- transfer the file to the db_ folder as shown in the image


6- In Production mode I click deploy
Schermata 2021-04-05 alle 19.05.19
But the database was not changed