Monday, May 31, 2010

Using schema shell to add a new table

Hi Folks, I've seen similar posts to this, but I'm still not having
any luck. I'm playing with the schema shell feature for the first time
on an existing app written in cakephp 1.2.7. I've generated a
schema.php file with an accurate depiction of my mysql database schema
using cake schema generate. Now I'd like to simulate that a separate
developer has added a table to the schema. So I copy the schema.php as
schema_2.php, add a new array definition representing a fake table
called street:

var $streets = array(
'id' => array('type' => 'integer', 'null' => false, 'default' =>
NULL, 'key' => 'primary'),
'name' => array('type' => 'string', 'null' => true, 'default' =>
NULL, 'length' => 50),
'type' => array('type' => 'string', 'null' => true, 'default' =>
NULL),
'created' => array('type' => 'datetime', 'null' => true, 'default'
=> NULL),
'modified' => array('type' => 'datetime', 'null' => true, 'default'
=> NULL),
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' =>
1))
);

I also created a model for this table in street.php:

<?
class Street extends AppModel
{
var $name = 'Street';

}
?>

I then try this: cake schema run update -dry -s 2. But this for some
reason assumes the street table already exists and indicates that it
will ALTER the table, which is obviously not what I want to do. I also
tried cake schema run create -dry -s 2. This is much more drastic, it
wants to drop all my tables then re-create them, something I
definitely don't want to do.

I'm running:
php 5.3
cakephp 1.2.7
apache2
mysql 5.1.47
mac os x (snow leopard)

Any ideas would be greatly appreciated. Thanks in advance.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: