Skipper - The ORM Designer Blog
  • Skipper - The ORM Designer
  • VsBuilds - Parallel building
  • Pulpo - Free Skipper CLI

New feature for CakePHP users – DB Schema export

Today I would like to introduce you a new upcoming feature for CakePHP users. Nowadays ORM Designer can export php classes for your model objects. But when you want to use CakePHP migrations, you have to make the DB changes manually. This would change in the next ORM Designer release. Besides model classes ORM Designer knows how to generate CakeSchema (http://book.cakephp.org/2.0/en/console-and-shells/schema-management-and-migrations.html) object class which defines a whole DB structure.

Usage of this new function is very simple. In your current ORM Designer model choose “Project object”

CakePHP schema management and migrations

In Project property window there is a new item Schema with child export-file.  Select “export-file” property and click on the button with three dots and choose export file for schema file.

Export CakePHP schema file

Now, if you export your model by using “Export to ORM” button, beside the model object files DB schema file will be also generated.

For our example DB schema file will look like this:

<?php
/* SVN FILE: $Id$ */
/* App schema generated by: ORM Designer (http://www.orm-designer.com) */
class AppSchema extends CakeSchema
{
  public $name = 'App';
  public $Contact =
    array (
      'ID' =>
        array (
          'type' => 'integer',
          'null' => 'true',
          'default' => 'NULL',
          'key' => 'primary',
          'length' => '4'
        ),
      'Name' =>
        array (
          'type' => 'string',
          'null' => 'true',
          'default' => 'NULL'
        ),
      'Age' =>
        array (
          'type' => 'integer',
          'null' => 'true',
          'default' => 'NULL'
        ),
      'indexes' =>
        array (
          'PRIMARY' =>
            array (
              'column' => 'ID'
            )
        )
    );
}

Note: This feature will be available in 1.4.0.420 and later.

05 Aug 2010