diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
index 4d1c2ad82..616d86318 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/MySQLDictionary.java
@@ -30,6 +30,7 @@ import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
import org.apache.openjpa.jdbc.kernel.JDBCStore;
import org.apache.openjpa.jdbc.kernel.exps.FilterValue;
import org.apache.openjpa.jdbc.schema.Column;
+import org.apache.openjpa.jdbc.schema.ForeignKey;
import org.apache.openjpa.jdbc.schema.Index;
import org.apache.openjpa.jdbc.schema.PrimaryKey;
import org.apache.openjpa.jdbc.schema.Table;
@@ -207,6 +208,37 @@ public class MySQLDictionary
+ getFullName(index.getTable(), false) };
}
+ /**
+ * Return ALTER TABLE <table name> DROP PRIMARY KEY
.
+ */
+ @Override
+ public String[] getDropPrimaryKeySQL(PrimaryKey pk) {
+ if (pk.getName() == null)
+ return new String[0];
+ return new String[]{ "ALTER TABLE "
+ + getFullName(pk.getTable(), false)
+ + " DROP PRIMARY KEY" };
+ }
+
+ /**
+ * Return ALTER TABLE <table name> DROP FOREIGN KEY
+ * <fk name>
.
+ */
+ @Override
+ public String[] getDropForeignKeySQL(ForeignKey fk, Connection conn) {
+ if (fk.getName() == null) {
+ String fkName = fk.loadNameFromDB(this,conn);
+ String[] retVal = (fkName == null) ? new String[0] :
+ new String[]{ "ALTER TABLE "
+ + getFullName(fk.getTable(), false)
+ + " DROP FOREIGN KEY " + fkName };
+ return retVal;
+ }
+ return new String[]{ "ALTER TABLE "
+ + getFullName(fk.getTable(), false)
+ + " DROP FOREIGN KEY " + fk.getName() };
+ }
+
public String[] getAddPrimaryKeySQL(PrimaryKey pk) {
String[] sql = super.getAddPrimaryKeySQL(pk);