Get the delta query to adjust the current database according to a given (list of) "CREATE TABLE"-, "CREATE DATABASE"-, "INSERT"- or "UPDATE"-statement(s).
It's not recommend to use INSERT or UPDATE statements with this function, as they are just handled "as-is".
NOTE:
You should use single quotes (') to give string type values (this is in fact
required for ENUM and SET fields).
KEYs for AUTO_INCREMENT fields should be defined in column_definition, otherwise
we had to detect the key type from the INDEX query and add it to the ALTER/ADD query.
If a column changes from "NULL" to "NOT NULL" we generate an extra UPDATE query
to prevent "Data truncated for column 'X' at row Y" errors.
The following query types are generated/marked and can be excluded:
'create_table'
'create_database'
'insert'
'update'
'drop_column'
'change_column'
'change_default'
'add_column'
'add_index'
'drop_index'
'alter_engine'
NOTE: it may be needed to merge an 'add_index' or 'drop_index' type query into an 'add_column'/'change_column' query (adding "AUTO_INCREMENT" for example)!
NOTE: collations and charset changes are ignored. It seems quite difficult to support this, and it seems to be best to handle this "manually".
Parameters:
array
$queries:
The list of queries for which the DB should be adjusted
array
$exclude_types:
Exclude query types (see list above).
boolean
$execute:
Execute generated queries? TODO: get this outta here!!!! (sooooo bloated!)
API Tags:
Return:
The generated queries. table_name => array of arrays (queries with keys 'queries' (array), 'note' (string) and 'type' (string)) There's usually just a single query in "queries", but in some cases additional queries are needed (e.g., 'UPDATE' before we can change "NULL" setting).