Proper Procedure To Rename Application Table Needed

Hello,

We recently had a central MySQL Innodb table in our DaDaBik web application get corrupted and appear that it was dropped.
Not sure what happened but it was definitely gone. So I turned on the DaDaBik maintenance mode flag and spread the word not to use the app. We had been making a lot of code changes and tweaking schemas and records lately so when I checked, the most recent stable backup was almost 2 wees old. Not good...

When we reconstructed a create table SQL statement with all the compatible fields from the backup and then updated everything that changed since then I thought the worst was over. Well, it wasn't.

We would repeatedly get errors with foreign keys being formatted wrong or having duplicate keys when we ran the new script so the table could not be re-created.This would happen even if we removed all the foreign key constraints from the create table statement.
We looked for duplicate key names in the information_schema tables but found none there and all the field types in each foreign key referenced table matched exactly. So, it looks like MySQL has other orphaned references to the now missing table saved somewhere so it will not let us create it again. The frm and ibd table files are gone so even a lower level data restore or repair are not possible at this point.

As a result we created the missing table schema under a new table name and were able to do this. Now we just need the app to reference the new table.

How do I incorporate this change into DaDaBik as there is no option to rename tables in either the DB Synchro tab or the Data tab.
We have added dozens of charts and custom plots and made way to many changes to this app to start from scratch again so any tips on how to proceed would be appreciated.

Thanks in advance,

-Todd

Support Details:
[pre]
You are using DaDaBIK version 10.1-Manarola enterprise, installed on 05-20-2020

System info
PHP Version: 7.2.5

mysql version: 5.5.5-10.2.31-MariaDB

Web server: Apache

Client: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36

[/pre]
 
So, we were able to move beyond this issue by doing the following:

1) Backup the entire database including all tables to an SQL dump file (schema and data).
2) Create a new database with a different name and import the entire dump file into it.
3) Rename the restored data table to the original missing table name (now that we are in a new database with no corruption the constraints will not prevent this.)
4) Edit the config_custom.php file and change the $db_name variable to the new database.
5) Assign the same user and password credentials as before to the new database.

Everything is mostly working again! The only remaining issue is some views did not get transferred over as part of this migration so now there are views listed as custom menu items in the app menu drop down but they do not load. Since those views are no longer in the pages based on views area in admin I do not know where these menu items are coming from. They must be located in the dadabik_ tables somewhere but I do not to mess with those.

My guess for this remaining issue is that I need to edit and re-add the missing views to point to the new database and tables and then install them from the pages area under other not installed views. Then I will be able to edit the custom menu entries and either keep them or delete them so the bad menu items are gone.

Hopefully this explanation helps someone else who experiences table corruption.

It would be nice if DaDaBik had an easy way to rename a table. That would have avoided the extra complexity of changing databases for recovering from such a small failure as a single table being corrupted with no way to restore it (fundamentally an an Innodb table engine issue and not DaDaBiks's fault).
 

deep64blue

DaDaBIK Guru
The way I have done this in the past is to UNINSTALL the table from the PAGES tab, then do whatever changes are needed and then INSTALL the table from the PAGES tab.

You have to redo any Forms Configuration / Permissions etc but it is a viable method I think.
 

eugenio

Administrator
Staff member
Hi all,
yes, the solution deep64blue explained is the "cleanest" one at the moment.

Best,
 
Hello,

I have the same problem with rename table.
I use DaDaBIK for prototyping and in this case, it is often so, that in a workshop the customer team change her requirements and so I must change also the name of a table in mysql.

I know, there is no function in DaDaBIK to change the table name via GUI.

But
1. perhaps exist an MySQL script that I can run in phpmyadmin that change all used old table names to new table name?
2. In which dadabik_* tables if the tablename used? (if no script exist and I must change the tablename manually.

Regards
 
Top