
    SSO Server database schema versioning.

Each database has numeric schema identifier that is stored in schema_version table.
Any change to schema or incompatible data change should be accompanied by database schema
update procedure. Versions should be successive increasing numbers.

Currently procedure for changing database schema or data update is as follows:

    Pre and post condition:
        Schema versions in sso-saml/schema/db-schema-1.sql
        and constant db_versioning_SchemaUtil::CURRENT_SCHEMA_VERSION should match.

    1. Find out what current schema version is. Version is specified as value of
    db_versioning_SchemaUtil::CURRENT_SCHEMA_VERSION constant.

    2. Make a copy of sso-saml/schema/db-schema-1.sql as
        sso-saml/schema/src/db/versioning/ddl-<schema version>.sql

    3. Copy latest sso-saml/schema/src/db/versioning/ddl-<schema version>.sql
        to sso-saml/schema/db-schema-1.sql

    4. Write update for previous version of database. Update script name
    db/versioning/Update<previous_version>to<new_version>.php
    Update script is implemented as class db_versioning_Update<previous_version>to<new_version>
    that implements method
    public function update($dbFile, $updatedDbFile);
    where
        $dbFile is input database file
        $updatedDbFile is name of updated copy of database file
    See for example class db_versioning_Update4to5.

    5. Set new value for db_versioning_SchemaUtil::CURRENT_SCHEMA_VERSION constant.

    6. Do not forget to add new files to source repository and test fresh installs
    and update installations.

Update procedure is initiated by db_versioning_SchemaUtil::update method that is invoked
from post-install procedure.


    TODO

1. Schema update procedure could be simplified if src/db/SchemaUtil.php is used in
installation procedure (this feature it is not implemented yet). This would make single
point of version information.

2. Database version 6: enforce foreign key restriction on delegation table
(src_type and dst_type should refer to primary key of selector_type)