#6 new
Michał Szajbe

running migration generated from db fails when created or modified field was present in db table

Reported by Michał Szajbe | April 7th, 2009 @ 05:03 PM

I generated a migration from db table that had created field defined.

Generated migration looks like this:

UP: 
  create_table: 

users:
  - modified
  no_dates: 
  ...




When I tried to run that migration it failed with SQL error. The SQL query was:

CREATE TABLE ... (..., default VARCHAR(255) DEFAULT 'modified', ...);

I looked in the code and I understand that no_dates option indicates that the script shouldn't try to add created and modified fields automatically if any of these fields was not present in the table the migration is generated from.

However it should include those fields in migration if they were present in the table, right?

So there must be something wrong in either building the yaml file or translating it to fields definitions.

The line that causes the SQL error is the line no 775 of migrate.php:

if (isset($fields[0])) $fields = array_merge($fields, $this->_getProperties($fields[0]));

However I am not sure if that's the only piece of code that should be modified to fix the issue. I bet not.

If you need some help with fixing this, please contact. As for now, I didn't have the time too look in the code closely enough to understand the whole philosophy behind treating created and modified fields differently than other fields, so I was not able to work on appropriate patch.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Pages