User Profile

User
 georgious
Location
 Sofia, Bulgaria
URL
 http://www.ovalpixels.com

Recent Articles

CakePHP YAML Migrations and Fixtures without PEAR

In his article ( [url]http://bakery.cakephp.org/articles/view/cake-db-migrations-v2-1[/url] ) at the Bakery Joel Moss describes how to use his CakePHP migrations shell. Although that project was my inspiration and I highly respect his work, his approach has several drawbacks: [ulist] [li] it uses PEAR - I don’t like it - that’s why I use CakePHP. I do not find it necessary to explain this - I guess it is highly subjective.[/li] [li] it is non-modular - you cannot use it to deploy applications - it is just a shell with no ‘core’[/li] [li] it cannot make a snapshot of your already existing schema - you haven’t used migrations yet? That’s something you will need.[/li] [li] it cannot merge your tables - that can be crucial when you already have different versions of the schema on different platforms and you just want them all to be standardized[/li] [/ulist]
  • Published by georgious 03/09/09 - 16:11
  • 10022 views
  • 7 comments

Recent Comments

Posted 11/03/2009 08:32am
I have some associative tables, in which I have double primary key,
yaml file generated is like this:

    companies_crafts: 
      company_id: 
        type: integer
        default: false
        length: 11
        primary: true
        - not_null
      craft_id: 
        type: integer
        default: false
        length: 11
        primary: true
        - not_null
      - no_id
      - no_dates
And while I try to migrate - it complains:

  Query: CREATE TABLE IF NOT EXISTS `companies_crafts`(
        `company_id` int(11) NOT NULL AUTO_INCREMENT,
        `craft_id` int(11) NOT NULL AUTO_INCREMENT,
        PRIMARY KEY  (`company_id`, `craft_id`));

And another thing: do I have to rename yml file with new version, after generating it from database structure?

well, that's right - looks like there shouldn't be an implicit auto_increment on those fields. note taken - I will have a look at how to fix this.
Posted 09/03/2009 12:39pm
Was odd at first, it took one time of "cake migrate help" to get the message similar to:

'schema_info' not avail for model 'Model'

The next time I ran "cake migrate help" the message was gone and the normal "help" message was there. I haven't looked into it but after that I was able to go up and down on my DB without a problem.


Hmm.. yeah, I hadn't thought about that - this happens because the shell uses a table called schema_info and creates it, if it is non-existent. Unfortunately, it looks like the check for its existence is made too late. I will have to go look into that...