I created a table named "Payments" and later on realized, that I needed to change the names and datatypes of 2 of its columns. I dropped the table and wanted to create it again - but now I get the error-message: "Can't create table 'dev_datenbank.payment' (errno: 150)"
CREATE TABLE Payment(
payment_id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
payment_gemeindeid INTEGER NOT NULL,
payment_initiator TIMESTAMP,
payment_zyklus INTEGER,
payment_received BOOLEAN DEFAULT false
);
ALTER TABLE Payment ADD FOREIGN KEY(payment_gemeindeid) REFERENCES Gemeinde(gemeinde_id);
I looked at similar problems here, but I haven't found a solution. Most of the times when others encountered this problem, it had to do with tables having different datatypes on the FK columns. But in my case both are INTEGER. Also the database-type of all columns is 'InnoDB'.
I assume that the foreign key constraint has not correctly been removed from MySQL. I checked in the table KEY_COLUMN_USAGE in the information_schema but I cannot see any remains here.
The other table is created as follows:
CREATE TABLE Gemeinde
(gemeinde_id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
gemeinde_name VARCHAR(50) NOT NULL,
gemeinde_amt INTEGER,
gemeinde_status INTEGER NOT NULL DEFAULT 1,
gemeinde_info VARCHAR(512)
);