Note that there are some explanatory texts on larger screens.

plurals
  1. PODoctrine generate-migrations-diff and migrate
    primarykey
    data
    text
    <p>I have tried to execute the cli command ./doctrine generate-migrations-diff and a version file has been created correctly in the right folder.</p> <p>The message is: <strong>generate-migrations-diff - Generated migration classes successfully from difference</strong></p> <p>Then I try to execute another cli command ./doctrine migrate and a message appears to me saying: <strong>migrate - migrated successfully to version #1</strong> but when I open the class any modification have been done. Why?</p> <p>This is the version1 file:</p> <pre><code>&lt;?php class Version1 extends Doctrine_Migration_Base { public function up() { $this-&gt;removeColumn('addresses', 'address_test'); } public function down() { $this-&gt;addColumn('addresses', 'address_test', 'string', '', array( 'fixed' =&gt; '0', 'unsigned' =&gt; '', 'primary' =&gt; '', 'notnull' =&gt; '1', 'autoincrement' =&gt; '', )); } } ?&gt; </code></pre> <p>This is the YAML. <strong>I have deleted the field: address_test</strong></p> <pre><code>Addresses: connection: doctrine tableName: addresses columns: address_id: type: integer(4) fixed: false unsigned: false primary: true autoincrement: true address: type: string() fixed: false unsigned: false primary: false notnull: false autoincrement: false city: type: string(150) fixed: false unsigned: false primary: false notnull: false autoincrement: false code: type: string(20) fixed: false unsigned: false primary: false notnull: false autoincrement: false country_id: type: integer(4) fixed: false unsigned: false primary: false notnull: false autoincrement: false base: type: integer(1) fixed: false unsigned: false primary: false default: '0' notnull: true autoincrement: false latitude: type: string(20) fixed: false unsigned: false primary: false notnull: false autoincrement: false longitude: type: string(20) fixed: false unsigned: false primary: false notnull: false autoincrement: false customer_id: type: integer(4) fixed: false unsigned: false primary: false notnull: true autoincrement: false </code></pre> <p>This is the BaseAddresses class generated by the <strong>migrate</strong> command: bindComponent('Addresses', 'doctrine');</p> <pre><code>/** * BaseAddresses * * This class has been auto-generated by the Doctrine ORM Framework * * @property integer $address_id * @property string $address * @property string $city * @property string $code * @property integer $country_id * @property integer $base * @property string $latitude * @property string $longitude * @property integer $customer_id * @property Countries $Countries * @property Customers $Customers * * @package ##PACKAGE## * @subpackage ##SUBPACKAGE## * @author ##NAME## &lt;##EMAIL##&gt; * @version SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $ */ abstract class BaseAddresses extends Doctrine_Record { public function setTableDefinition() { $this-&gt;setTableName('addresses'); $this-&gt;hasColumn('address_id', 'integer', 4, array( 'type' =&gt; 'integer', 'fixed' =&gt; 0, 'unsigned' =&gt; false, 'primary' =&gt; true, 'autoincrement' =&gt; true, 'length' =&gt; '4', )); $this-&gt;hasColumn('address', 'string', null, array( 'type' =&gt; 'string', 'fixed' =&gt; 0, 'unsigned' =&gt; false, 'primary' =&gt; false, 'notnull' =&gt; false, 'autoincrement' =&gt; false, 'length' =&gt; '', )); $this-&gt;hasColumn('city', 'string', 150, array( 'type' =&gt; 'string', 'fixed' =&gt; 0, 'unsigned' =&gt; false, 'primary' =&gt; false, 'notnull' =&gt; false, 'autoincrement' =&gt; false, 'length' =&gt; '150', )); $this-&gt;hasColumn('code', 'string', 20, array( 'type' =&gt; 'string', 'fixed' =&gt; 0, 'unsigned' =&gt; false, 'primary' =&gt; false, 'notnull' =&gt; false, 'autoincrement' =&gt; false, 'length' =&gt; '20', )); $this-&gt;hasColumn('country_id', 'integer', 4, array( 'type' =&gt; 'integer', 'fixed' =&gt; 0, 'unsigned' =&gt; false, 'primary' =&gt; false, 'notnull' =&gt; false, 'autoincrement' =&gt; false, 'length' =&gt; '4', )); $this-&gt;hasColumn('base', 'integer', 1, array( 'type' =&gt; 'integer', 'fixed' =&gt; 0, 'unsigned' =&gt; false, 'primary' =&gt; false, 'default' =&gt; '0', 'notnull' =&gt; true, 'autoincrement' =&gt; false, 'length' =&gt; '1', )); $this-&gt;hasColumn('latitude', 'string', 20, array( 'type' =&gt; 'string', 'fixed' =&gt; 0, 'unsigned' =&gt; false, 'primary' =&gt; false, 'notnull' =&gt; false, 'autoincrement' =&gt; false, 'length' =&gt; '20', )); $this-&gt;hasColumn('longitude', 'string', 20, array( 'type' =&gt; 'string', 'fixed' =&gt; 0, 'unsigned' =&gt; false, 'primary' =&gt; false, 'notnull' =&gt; false, 'autoincrement' =&gt; false, 'length' =&gt; '20', )); $this-&gt;hasColumn('customer_id', 'integer', 4, array( 'type' =&gt; 'integer', 'fixed' =&gt; 0, 'unsigned' =&gt; false, 'primary' =&gt; false, 'notnull' =&gt; true, 'autoincrement' =&gt; false, 'length' =&gt; '4', )); } public function setUp() { parent::setUp(); $this-&gt;hasOne('Countries', array( 'local' =&gt; 'country_id', 'foreign' =&gt; 'country_id')); $this-&gt;hasOne('Customers', array( 'local' =&gt; 'customer_id', 'foreign' =&gt; 'customer_id', 'onDelete' =&gt; 'CASCADE')); } } </code></pre> <p>In some website I have read that I have to execute the command: <strong>build-all</strong> in order to generate a version updated of the class addresses but I get this error:</p> <pre><code>SQLSTATE[HY000]: General error: 1005 Can't create table 'web63db1.#sql-3e6_11d' (errno: 121). Failing Query: "ALTER TABLE addresses ADD CONSTRAINT addresses_customer_id_customers_customer_id FOREIGN KEY (customer_id) REFERENCES customers(customer_id) ON DELETE CASCADE". Failing Query: ALTER TABLE addresses ADD CONSTRAINT addresses_customer_id_customers_customer_id FOREIGN KEY (customer_id) REFERENCES customers(customer_id) ON DELETE CASCADE </code></pre> <p>What have I do? Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload