Some people want order in their Databases.
Like, wanting the last 2 columns to be date_created and date_modified;
But after a while, business requirements and lazyness creep in,
and the dreams fade. And they're stuck with an ugly unordered DB.
Clone it the repo.
Enter the directory
Start the server
git clone [email protected]:jardayn/database_reorderer.git
cd database_reorderer
php -S localhost:8000
Go to http://localhost:8000
Enter your DB info: Acc/Pass/Host/DbName
Enter the order of columns you want at the start and the end of your table.
Click Submit. You will get a list of tables in the DB.
If you don't want to reorder some tables - you can delete which one's you don't want reordered.
Then click submit again.
You'll get a list of queries that you need to run to satisfy your OCD
If everything is in order - it will ignore the table.
If you want id,first_name,last_name to be the first columns, and the first 2 columns of the table ar id,first_name - it will only move the last_name column.
But, if the final columns are not in perfect order - it's gonna generate the query to adjust all of them.
The DBRO will ignore columns that do not exist on a table. So if you have only id,last_name but not first_name - it will reorder the table to have id,last_name in the front. Same behavior for the end of the table.
I am doing this on a high bandwidth database, how do I avoid breaking everything with Read/Write locks?
Queries generated by the DBRO do not modify the DB, and I've added the "LOCK=NONE" to the queries, so you can avoid those pesky locks
Not now. But that's coming in the near future
Not yet. Maybe one day.
Whoops.
Make an issue or PR. I'll see what can be done.
Why are you not copying the SCHEMA into another table, reordering it, and and then moving the data into the new reordered table?
It's a possibility, but that'll seriously screw with large tables.
Cos it's gonna lock them up until the data is transferred from table A to table B. Will it be much faster? Yes. But I prefer not taking my DBs down.
But one day, I'll add this as an option.
Yes.