I can generate my models and schema.yml file based on an existing database. But when I try to do it the other way around using Doctrine::createTablesFromModels() i get an error:
Syntax error or access violation: 1064
So either of these works:
Doctrine::generateYamlFromDb(APPPATH . 'models/yaml');
Doctrine::generateYamlFromModels(APPPATH . 'models/yaml', APPPATH . 'models');
Doctrine::generateModelsFromYaml(APPPATH . 'models/yaml', APPPATH . 'models', array('generateTableClasses' => true));
Doctrine::generateModelsFromDb(APPATH . 'models', array('default'), array('generateTableClasses' => true));
But this fails (it drops/creates the database and around 50 tables):
Doctrine::dropDatabases();
Doctrine::createDatabases();
Doctrine::createTablesFromModels();
The partially outputted SQL query shows that the error is around the Notification object which looks like this:
Any leads would be highly appreciated!
<?php
// Connection Component Binding
Doctrine_Manager::getInstance()->bindComponent('Notification', 'default');
/**
* BaseNotification
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @property integer $n_auto_key
* @property integer $type
* @property string $title
* @property string $message
* @property timestamp $entry_date
* @property timestamp $update_date
* @property integer $u_auto_key
* @property integer $c_auto_key
* @property integer $ub_auto_key
* @property integer $o_auto_key
* @property integer $notified
* @property integer $read
* @property integer $urgence
*
* @package ##PACKAGE##
* @subpackage ##SUBPACKAGE##
* @author ##NAME## <##EMAIL##>
* @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $
*/
abstract class BaseNotification extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('Notification');
$this->hasColumn('n_auto_key', 'integer', 4, array(
'type' => 'integer',
'fixed' => 0,
'unsigned' => false,
'primary' => true,
'autoincrement' => true,
'length' => '4',
));
$this->hasColumn('type', 'integer', 1, array(
'type' => 'integer',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => true,
'autoincrement' => false,
'length' => '1',
));
$this->hasColumn('title', 'string', 50, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => true,
'autoincrement' => false,
'length' => '50',
));
$this->hasColumn('message', 'string', null, array(
'type' => 'string',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => true,
'autoincrement' => false,
'length' => '',
));
$this->hasColumn('entry_date', 'timestamp', 25, array(
'type' => 'timestamp',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => true,
'autoincrement' => false,
'length' => '25',
));
$this->hasColumn('update_date', 'timestamp', 25, array(
'type' => 'timestamp',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '25',
));
$this->hasColumn('u_auto_key', 'integer', 4, array(
'type' => 'integer',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => true,
'autoincrement' => false,
'length' => '4',
));
$this->hasColumn('c_auto_key', 'integer', 4, array(
'type' => 'integer',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '4',
));
$this->hasColumn('ub_auto_key', 'integer', 4, array(
'type' => 'integer',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '4',
));
$this->hasColumn('o_auto_key', 'integer', 4, array(
'type' => 'integer',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'notnull' => false,
'autoincrement' => false,
'length' => '4',
));
$this->hasColumn('notified', 'integer', 1, array(
'type' => 'integer',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'default' => '0',
'notnull' => true,
'autoincrement' => false,
'length' => '1',
));
$this->hasColumn('read', 'integer', 1, array(
'type' => 'integer',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'default' => '0',
'notnull' => true,
'autoincrement' => false,
'length' => '1',
));
$this->hasColumn('urgence', 'integer', 1, array(
'type' => 'integer',
'fixed' => 0,
'unsigned' => false,
'primary' => false,
'default' => '0',
'notnull' => true,
'autoincrement' => false,
'length' => '1',
));
}
public function setUp()
{
parent::setUp();
}
}