Cannot Recreate empty database with open existing project off a backup

Ok, so I’m having a bit of a panic here. I’ve spent the past 3 months building out my first web app. It was going very well, its a large project so a lot of time but I was making good progress and nearing the end. I backup my wappler project folder twice a day to my google drive. This week to my dismay my pc’s hard drive failed completely. I of course lost my local docker database when this happened. I thought ok no problem, I’ll download my wappler project backup, import project and be back up no problem. The actual data in my database was not important at this stage, I only need to respin up the database empty and I’ll be golden.
So I’ve Imported my project onto my fresh windows install and I’m seeing some weird stuff I am hoping some of you have experienced this before and can help me out. When I check my db connections at first it will show my tables, until I click into one of them and then they disappear and are simply gone.

dbexample1

I can see the changelog though

When I test the connection it is showing its ok

but if I try and view any of my pages locally I get a 404 error
404notfound

I really am out of my depth here when it comes to docker and databases but I have checked the database logs shown in the wappler console and no obvious errors are being shown. I;m hoping theirs some super obvious thing I have overlooked here. Weirdly enough, I have opened the same project on my laptop and the database is missing the tables as well even though it will initially show them, however I do not receive a 404 error, I can navigate my web app as normally…which just confuses me even more

Thank you for your time

I hate these moments...

Maybe the following can help, although am not entirely sure as am not a Docker expert...

This is contained within the following documentation:

https://docs.wappler.io/t/web-development-with-docker-part-2-databases-and-terminals/13546

1 Like

When you do backups do you also use the database manager backup option:

Screenshot 2022-01-11 at 22.14.05

I'm not entirely sure but when I backed up what I did was backup after say my first table added so id have one change on the list ticked.

Then I added say 5 more changes which also get added as green ticks but are not backed up with the button in the screenshot clicked then if you shutdown and restart you notice the tables are gone but in the example case the change log remains but now only one is green as it was backed up and the other 5 for example are orange.

So to get these 5 back right click the word changes and apply latest brings back the tables (data will be lost not sure about if you created a seed if it would remain but without im pretty sure its lost not 100% sure)

2 Likes

thanks for your quick replies, I had absolutely no clue that such a option existed for database backups which makes me feel real dumb now. If freshly import my project I can open up my db tables but if i hit fetch data I get this. I tried just importing it and saving the database button, but when I redploy it removes the db tables like before.

I’m guessing I can create a fresh database and manually re-add the 400 table items and everything will work properly again?

What you could try is refresh schema on the database by right clicking db it seems to me these tables are just not updated as gone

Once the tables no longer show then go to changes (you may be able to jump straight to this but not 100% sure) and apply latest if they are orange and not checked hopefully this will rebuild the structure atleast.

Make sure you can import the project or create a copy just incase anything goes wrong here

1 Like

As well as the above response by @Sorry_Duh you could try right clicking on a table and View/Edit, see if that opens the table, and if it does then try to add a new record to it?

Don't feel that way! We have all done similar. At least you know for future reference.

1 Like

Yea I tried the refresh schema and tried to apply a new different change points, got errors like the following one dbexample6

I really do appreciate the helpful advice, def will never make this mistake again going forward. I will try and rebuild the db from scratch and save it from now on :slight_smile:

At least you can use what you can see as a guide. Hopefully won't take too long, and in most circumstances you'll probably make it better, that is my experience. I've made some epic mistakes in my time. I once truncated several tables (tens of thousands of records in each) believing I was in a development environment only to get dozens of e-mails about missing data...

1 Like

Oof yea thats a good one. I do know that I can improve parts of it from where I started months ago as I knew literally nothing about web dev beforehand :slight_smile:

1 Like

Great video series on MySQL, still relevant despite being a few of years old:

1 Like

I have also completely redesigned my structure at points a few things I have started doing is

  1. small changes for example only add one database table at a time, save the change on to the next this way if there’s a small error the schema won’t get as messed up you can also see everything is okay with each table as you go.
  2. if you see a error show be wary of saving structure as sometimes half of a change works refresh schema and maybe ever roll back the change if it looks incorrect (and delete the change once rolled back)
  3. I would also use this as a oppertunity to add relations into tables if needed as editing fields to be one after can cause issues and errors I found it much easier to make it a relation off the get go (relations are used in cases like you delete a record from say table A it removes the corresponding record in table B an example of this would be having a users table then a table for their favourite movies for example in most cases if you delete the user the movies would also want removing )

Just a few things ive noticed everyone has methods slightly different but hope this helps

4 Likes

@TheBotfather

How did you get on with rebuilding your Project?

I always use a tool like phpmyadmin to create the database & its particulars.
Never from a program like Wappler or any other program that is not a Data Management program from the start.

I then create the tables and let Wappler discover them and then I save that state of “knowledge” in Wappler.

I ALWAYS 100% of the time do SQL Exports of each table and save them in .sql files. These have never failed me.

Those are the files I use for setting up the online database.

Everytime I might make a change through Wappler that changes a table I also do a quick SQL export from my main database admin tool like phpmyadmin.

No one should work long and hard on code that relies on database tables solely through a code tool. Onsite (local or remote) administration should always be initiated, backed up & closed with an actual dedicated database administration tool.

Sometimes the schema may change between localhost and online because the environmental setups may have key differences that would entail even having to change a data type for a field – particularly dealing with numeric values and what are the options offered by the online database version, for instance.

In that case I always keep the online database & tables schemas & relationships safely backed up and downloaded to my own computer. 2 or 3 times (just to feel better).

2 Likes

I have mostly got everything back working. A bit back and forth remembering exactly what I had used name-wise but it’s almost all functional again. A big thanks to all you guys in this great community. Really is a awesome place to be learning

2 Likes