|All requests||>||What is the best PHP database schema ...||>||Request new recommendation||>||Featured requests||>||No recommendations|
by Till Wehowski - 7 years ago (2015-08-07)
I wish to be able to change the applications database schema at a later point easily.
So I need to version the tables structures (table names, field names, keys, etc.).
And convert DBs between versions.
Any sugestions for existing solutions?
I do NOT need a class to execute queries.
This class does exactly what you need. check here: http://www.phpclasses.org/metabase for more info
1. by Manuel Lemos Reply- 7 years ago (2015-08-07)
Well the Metabase package was created with to be a database abstraction layer that supports also schema management.
You can define the database schema of tables, fields, keys, indexes, etc.. in a XML format file.
Then you tell the schema manager to install that schema.
If you want to update the schema, just change the XML schema file and tell the schema manager to update the database performing the necessary changes.
This way you add your application schema file to your project repository, so you can have it versioned too like any other file in the project.
I have been using things for many years and it enabled great productivity and low risk of screwing up your database performing part of the changes when you request changes not supported by the underlying database.
As for a class that does not execute queries, this is tricky. The problem is that Metabase abstracts the table creation and alteration processes. So the resulting SQL queries will be different depending on the database.
I don't know why you do not want to execute the schema changes, but want can be done is to improve Metabase to log queries instead of executing them.
2. by Till Wehowski - 7 years ago (2015-08-07) in reply to comment 1 by Manuel Lemos Reply
Well, it maybe CAN execute queries, but I just use PDO and other classes for this task. As for you said required queries are driver dependent I will try this class, thank you! It looks like it provides exactly what I need.
3. by Manuel Lemos Reply- 7 years ago (2015-08-07) in reply to comment 2 by Till Wehowski
Yes, PDO did not exist when this package was created. Still PDO does not provide all the portability you need.
It would be possible to add a PDO driver to this package but then it would require also sub-drivers for each other database.
This was done a long time ago with ODBC because it was the only was to access Microsoft Access databases but it is a lot more work.