[ https://issues.apache.org/jira/browse/DDLUTILS-150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12464267 ] Thomas Dudziak commented on DDLUTILS-150: ----------------------------------------- Do you also (before calling alterTables) change the type of the referenced primary key ? > Trying to change a column makes ddlutils want to drop non-related foreign keys which fails with for example "Can't DROP 'text_docs_FK_meta_id_meta'; check that column/key exists" > ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > > Key: DDLUTILS-150 > URL: https://issues.apache.org/jira/browse/DDLUTILS-150 > Project: DdlUtils > Issue Type: Bug > Components: Core - MySql > Environment: MySQL 5.0.20-something, MySQL 5.0.32 on Linux, InnoDB tables. > Reporter: Christoffer Hammarström > Assigned To: Thomas Dudziak > Attachments: DDLUTILS-150.patch > > > I'm trying variations on the following code: > org.apache.ddlutils.model.Database model = platform.readModelFromDatabase(null); > Table table = model.findTable("text_docs"); > Column templateNameColumn = table.findColumn("template_id"); > templateNameColumn.setType("VARCHAR"); > platform.alterTables(model,false); > Trying to change any column makes ddlutil try to drop unrelated foreign keys, which in my case fails with the following stack-trace: > org.apache.ddlutils.DatabaseOperationException: Error while executing SQL ALTER TABLE text_docs > DROP INDEX text_docs_FK_meta_id_meta > at org.apache.ddlutils.platform.PlatformImplBase.evaluateBatch(PlatformImplBase.java:331) > at org.apache.ddlutils.platform.PlatformImplBase.alterTables(PlatformImplBase.java:573) > at org.apache.ddlutils.platform.PlatformImplBase.alterTables(PlatformImplBase.java:507) > ... snipped my classes ... > Caused by: java.sql.SQLException: Can't DROP 'text_docs_FK_meta_id_meta'; check that column/key exists > at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2847) > at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1531) > at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1622) > at com.mysql.jdbc.Connection.execSQL(Connection.java:2370) > at com.mysql.jdbc.Connection.execSQL(Connection.java:2297) > at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1289) > at org.apache.commons.dbcp.DelegatingStatement.executeUpdate(DelegatingStatement.java:225) > at org.apache.commons.dbcp.DelegatingStatement.executeUpdate(DelegatingStatement.java:225) > at org.apache.ddlutils.platform.PlatformImplBase.evaluateBatch(PlatformImplBase.java:309) > ... 33 more > The ddl for the table looks like this: >