Most people don't see value is this and perhaps they're right.
But the value I see is this:
- To re-affirm the abstractions that we have created.
- A spring-cleaning for years of workaround and hacks.
- To permit exploration of new applications (maybe in new environments).
These should be wrapped up in PDB helpers. If not portable, then behind an adapter check and restricted from the user.
Key offenders:
- AdminController
- DbToolsController
- ManagedAdminController
- Export
- ExportDBMS_MySQL
- ExportDBMS_SQLite
- File
Defaults should be respected. Weak constraints lead to dirty data.
Either commit to:
- hacky (genuinely dangerous) editing schemas, or
- drop column, create column with FK
Instead of dropping the column, we could preserve data by renaming it to something like old_<colname>_xyz
.
Then perhaps:
UPDATE OR IGNORE target_table AS t1
SET new_col = (
SELECT old_col
FROM target_table AS t2
WHERE t1.id = t2.id
);
This also applies to MySQL. The current 3x query solution is pretty gross.
Currently PdbHelpers::normalizeType() is MySQL specific.
Normalise these into distinct values. Maybe somehow deprecate the string style.
This will help support for other backends (Sqlite uses CHECK).
Perhaps enum/set lookups could be done from a serialized schema instead of the database.
There are a lot of assumed functions, particular for date formatting/mangling.
But lucky us, sqlite (and also baked into PDO) lets us create custom functions that call back into PHP. So the sky is the limit.
I would also suggest that we create a custom collation so we don't lose our lovely unicode comparisons.