Login   Register  
PHP Classes
elePHPant
Icontem

Schema Defines DB Name

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      Metabase  >  All threads  >  Schema Defines DB Name  >  (Un) Subscribe thread alerts  
Subject:Schema Defines DB Name
Summary:Hard-coding the database name limits usefulness
Messages:3
Author:Devin
Date:2007-01-12 13:31:34
Update:2007-01-14 09:28:05
 

  1. Schema Defines DB Name   Reply   Report abuse  
Picture of Devin
Devin
2007-01-12 13:31:34
I have started using metabase for a project and was considering using the manager and schema, but there is a design decision which I don't understand. The name of the database if hard-coded into the schema definition. This may not accomidate all the user's setups, where they may have only a single database with a set name assigned to them. Shouldn't the database name be passed in the arguments parameter?

Also, it isn't clear from the documentation if I am allowed to have multiple <was> elemenats, for example if upgrading from more than one version.

Also, I'm not sure I understand the <create> element. What happens if I try to update a database and the new schema contains the <create> element? Will it fail because the database is already created?

Thanks,
Devin Bayer

  2. Re: Schema Defines DB Name   Reply   Report abuse  
Picture of Manuel Lemos
Manuel Lemos
2007-01-12 20:36:37 - In reply to message 1 from Devin
You use variable tags to turn schema definition parameters configurable from the schema setup script. For instance to make the database name a parameters you can have it this way:

<database>

<name><variable>database_name</variable>

...

Then you should set the database_name parameter to define the database name when the schema is installed.


You can install different databases schemata under the same database. Just set the database name to be the same.

If you only have a single database available, you can create the database separately, and then set the <create> parameter to 0 in the schema definitions.

The <create> parameter is only considered in the first time that a database schema is installed. So it does not affect database schema upgrades.

Keep in mind that Metabase schema manager determines whether a schema is being installed for the first time or it is being upgraded, by looking whether the previously installed schema file already exists.

If you are running in safe mode or for some other reason PHP scripts cannot write files, you may need to copy the installed schema file manually, as Metabase manager may not be allowed to do it.


In each element you can only have one was definition. What matters is that the value in the was element matches the name of that element in the environment where the schema was installed. Otherwise, the manager will not be able to correctly determine which schema table or field is to be renamed.

  3. Re: Schema Defines DB Name   Reply   Report abuse  
Picture of Devin
Devin
2007-01-14 09:28:06 - In reply to message 2 from Manuel Lemos
Thanks for the clear explaination.