PHP Classes
elePHPant
Icontem

Database metadata: Update a MySQL database schema using on metadata

Recommend this page to a friend!
  Info   Screenshots Screenshots   View files View files (9)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2006-07-23 (10 years ago) RSS 2.0 feedNot enough user ratingsTotal: 662 All time: 4,649 This week: 920Up
Version License Categories
dbmedata 1.0GNU General Publi...Databases
Description Author

This package can be used to update the schema of a MySQL database.

It takes the metadata that defines the schema and compares to the schema of a MySQL database, eventually already installed, and applies the necessary alterations to update the schema.

Picture of Nico den Boer
Name: Nico den Boer <contact>
Classes: 2 packages by
Country: Czech Republic Czech Republic

Details
Short description:
This class can update a database structure based on metadata in a SQL script

Detailed description:
If you deploy your webapplication to more then one server, you need to apply the same structure updates and perhaps also the same user data patches on all servers in a similar way. Did you ever wonder how you can smoothly organize this ?

This class reads a sql script with metadata, then updates the database structure accordingly and finally applies patches on user data.

A user interface for editing the metadata is not provided.
Code is written in PHP5.

Description of files:
update.php
	Main page to execute a update.
class.mysql.db.maint.inc.php
	Main class which arranges update of database structure
class.backbone.inc.php
	Class with some generic utility methods
class.metadata.inc.php
	Class with utility methods for metadata
classes.mySql.inc.php
	Classes with database abstraction for MySql
class.sqlBuilder.inc.php
	Class to build a SQL INSERT or UDPATE
config.database.inc.php
	File with database access config parameters
InsertMetaData.sql
	SQL CREATE script, for the required tables

Copyright:
Nico den Boer
NL: www.denboer-ims.nl, info@denboer-ims.nl
CZ: www.nicodenboer.com, nico@nicodenboer.com
However, you are free to copy and use the code as you like ;)

Installation:
1) Create a empty database dbmetadata
2) Execute the script InsertMetaData.sql
3) Open the script InsertMetaData.sql and remove all text starting from line
/* Remove the part below after initial installation */
4) Run the page update.php to see if it works :)

After installation:
1) Edit the metadata in the tables db_tables, db_fields, db_indexes
2) Create a new script InsertMetaData.sql with a full backup of db_tables, db_fields, db_indexes
3) If you have user data updates, update the page update.php with relevant patches
4) Distribute the new files update.php and InsertMetaData.sql to (the webservers of) your customers
5) Instruct your customers to run update.php (or add a auto-update function to your application to do it all automatically)

Screenshots  
  • snapshot1.png
  Files folder image Files  
File Role Description
Plain text file classes.mySql.inc.php Class Baseclass for Database abstraction for MySql
Accessible without login Plain text file class.mysql.db.maint.inc.php Class Arranges update of database structure, based on metadata
Accessible without login Plain text file update.php Appl. Main page to execute a update.
Plain text file class.backbone.inc.php Class Class with some generic utility methods
Plain text file class.metadata.inc.php Class Class with utility methods for metadata
Plain text file class.sqlBuilder.inc.php Class Class to build a SQL INSERT or UDPATE
Plain text file config.database.inc.php Conf. Database config
Plain text file InsertMetaData.sql Data SQL CREATE script, for the required tables
Plain text file readme.txt Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 0%
Total:662
This week:0
All time:4,649
This week:920Up
User Comments (1)
Excellent
7 years ago (kishore kumar)
70%StarStarStarStar