> We can use the SVN revision as version to make the update bulletproof
> (it's too easy to forget to change a $database_level variable ;-)
>
> Sidenote: I just learned that svn does keyword substitution only if you
> tell it to do so. A good SVN documentation is on
> http://svnbook.red-bean.com/en/1.4/svn.advanced.props.special.keywords.html
Yes, that's an excellent manual !
>
> You already know that I like the S9Y database code. I have taken an idea
> from there: Placeholders like {AUTOINCREMENT}.
Will look later
>
> Simply use CREATE TABLE IF NOT EXISTS ;-) (given PgSQL supports it).
Yes, that was my problem - I don't think PostgreSQL does.
> I don't know if PgSQL supports the SHOW TABLES command or if we have to
> read from information schema
> http://www.postgresql.org/docs/8.2/interactive/infoschema-tables.html
Probably.
> Another option is to simply ignore the error ;-)
I couldn't - as db_query was calling 'die()' when it failed.
> The basic idea is good.
>
> However, I change the do_upgrade function to use a classical
> for ($i = 1; $i <= 10; $i++)
> loop and function_exists(). This awoids the need to sort the upgrade
> functions (which will break when we have >99 functions) ;-)
> Note that you may not use leading zeros!
Can they not be ordered lexiographically (spelling?) which would fix
that issue; or alterantively, the script 'casts' the number into
something with enough leading zeros as required using printf?
>
> I also added the option to create upgrade_<number>_mysql and
> upgrade_<number>_pgsql functions for database-specific changes.
I thought of that - but decided to not bother splitting it into two
seperate bits - thinking that if all of a change was in one statement it
would make it easier to follow. Of course, I could be mistaken about
this.
> > The only problems with the below is that it can't run on it's own
> > without the table already existing - I can't seem to use
> > db_query($sql) if the table doesn't exist and catch the error. Does
> > this imply db_query($sql) needs updating to return some sort of error
> > code or call trigger_error() instead?
>
> I have added an optional $ignore_error parameter to db_query ;-)
Cool, thanks.
> I also dived into DOCUMENTATION/* and the SVN log and added all needed
> update commands to upgrade.php.
Excellent.
> There are still several TODO notes in upgrade.php, especially related to
> PgSQL.
I'll try and resolve these soon.
> While talking about database upgrade:
> I propose we should
> - create the tables within upgrade.php (maybe we should rename it ;-)
> - do all future database changes as ALTER statements within upgrade.php
> - the function numbers should always be the SVN revision numbers of the
> change
> - drop DATABASE_*.TXT
> - remaining question: where do we put the GRANT statements etc.?
> Or can we assume that people who run a mailserver know how to grant
> database permissions?
> - drop DOCUMENTS/TABLE_BACKUP_MX.TXT and DOCUMENTS/TABLE_CHANGES.TXT and
> remove the references to these files in DOCUMENTS/UPGRADE.TXT
>
All good ideas to me. If it's easy enough to write, it does make more
sense to create the initial database structure from 'upgrade.php' as
well as handling anything else.
You've been busy!
thanks
David.
--
David Goodwin
[ david at codepoets dot co dot uk ]
[ http://www.codepoets.co.uk ]
|