Table and columns OK

Posted on 2005-08-18 04:59:35 EEST.

Good to know, first midgard database was modified automagically with midgard-schema command line tool which reads Midgard Schema XML file and use GObjects to modify database.

I had no this pleasure to create tables and columns ( but I will soon :) and I was able to modify database defined in new Midgard config file.

Usage is quite simple and trivial now.
`midgard-schema filename`



Filename is name of the file which exists in main midgard config directory.
/etc/midgard/conf.d in my case ( we always follow prefix defined for midgard-core ).

I used new OpenPSA2 schema and new MidCOM schema (global Midgard schema is used automagically) and it took "only" 35 seconds to modify database. It could be faster anyway , but I couldn't find any good way to create column if they not exist already in database. So what midgard_object_create_storage function does is:
1) Try to alter table and add column
2) if add fails try to modify it
( all in all types may change and database must be updated )

What about some usefull debug argument used with midgard-schema? There is no need to have it. Debug level is defined in configuration file. So database modification output ( with Loglevel set to message ) looks like this:

midgard-core(m):  Table and columns for 'NewMidgardSnippet' OK
midgard-core(m):  Column password for password property not created


Something's bad with password property ( message is not clever at this point , but believe me I modify table and write this blog, and this is initial midgard-schema usability ).

Let's switch Loglevel to debug ( default is warning , so such messages won't be printed except errors and warnings ).

Schema(d):  Type NewMidgardPerson
midgard-core(d):  query=CREATE TABLE IF NOT EXISTS person(id int(11) NOT NULL auto_increment, PRIMARY KEY(id))
midgard-core(d):  query=ALTER TABLE person ADD password varchar(255)
midgard-core(d):  query failed: Duplicate column name 'password'
midgard-core(d):  query=ALTER TABLE person MODIFY password varchar(255) 
midgard-core(d):  query failed: Specified key was too long. Max key length is 500


I wonder about this error. PRIMARY KEY and indexes wasn't touched.

BTW, log messages ( which can be logged to file ) starts with log domain name.So here this is very clear that we use external application which uses midgard-core."Schema" is a domain name defined for midgard-schema application.

Now think about midgard-apache and midgard-php combined log file and you will get very clear picture of Midgard :)

With possibility to add own messages to log file, even from PHP script you will source of your problem faster and easier. Just watching step by step what is going on :)

Back

Layout Copyright © 2006 Finnish Teleservice Center Ltd Oy - Site Powered by Midgard CMS