Bug #71955 Synchronize breaks on add column + change column
Submitted: 6 Mar 2014 9:16 Modified: 25 May 2018 12:23
Reporter: Bruno Michalski Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Workbench: SQL Editor Severity:S3 (Non-critical)
Version:6.0.9 OS:Linux
Assigned to: CPU Architecture:Any
Tags: synchronize alter table

[6 Mar 2014 9:16] Bruno Michalski
Description:
When altering a table, namely adding columns, sql script generated tries to first reorder the fields and then creates new columns.

Say:

ALTER TABLE `some_table` 
CHANGE COLUMN `type` `type` ENUM('type1','type2') NULL DEFAULT NULL AFTER `new_column`,
ADD COLUMN `new_column` DECIMAL(10,2) NULL DEFAULT NULL AFTER `other_column`;

of course server balked at it saying that 'new_column' does not exist (in line 2 in AFTER statement).

How to repeat:
Create a new column and move some other column to be after it then try to synchronize.

Suggested fix:
Perhaps move ADD COLUMN to the front of the statement before any CHANGE COLUMN?
This could create conundrums of its own if new columns are supposed to be after the rearranged columns which wont be rearranged at the point of creating new columns yet, but this can be easily remedied by running synchronize twice. Now its impossible to finish it - every time it throws 'unknown column' error.
[25 Aug 2014 14:43] Marcin Szalowicz
Thank you for the bug report.