I am creating an web application which is replacing the outdated one I currently use. The database is also outdated and horribly structured. For testing purposes I would like to export the old database and load it into the new one to have test data for the new web application. However, because of the schema changes to the database I need to manually change:
- Table names
- Column names
Example:
Old Database Table: part
id | date | user
New Database Table: apx_parts
id | date_created | user_id
Is there a MySQL tool or something to automate this? Would it have to be self-written in a scripting language?
Edit
Just to clarify, the reason I want it automated is because I want to use the most recent data that the old application is collecting.
You’re probably thinking about using mysqldump to copy the schema and data over. Instead, think about exporting the data by itself.
Create the new database and tables as you normally would.
Export the data from the old database using SELECT…INTO. Column names don’t matter here. If there are new columns in the new database, you can compute their values in this SELECT or just ignore them.
Import the data into the new database using LOAD DATA
Good luck.