0
Guys I’ve researched several other topics about this bug and none solved my problem so I’m posting here for you. Here’s the thing: I have a table called "members" that already has content and I’m creating a new table called membro_photos that has nothing in it. In this table I have the following columns: id, membro_id, photo. Both member and table id members are set to the following configuration: int-11 and both tables are in the Innodb engine. My problem is that when I try to create Foreign key in the table membro_photos it gives me error 1512. Why does this happen? and how to solve?
mysql> desc membros;
+---------------------+------------------+------+-----+---------+----------------
| Field | Type | Null | Key | Default | Extra |
+---------------------+------------------+------+-----+---------+----------------+
| id | int(11) unsigned | NO | PRI | NULL | auto_increment |
| nome | varchar(100) | YES | | NULL | |
| nascimento | varchar(10) | YES | | NULL | |
| falecimento | varchar(10) | YES | | NULL | |
mysql> desc membro_images;
+---------------+--------------+------+-----+---------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-----------------------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| membro_id | int(11) | YES | MUL | NULL | |
| name | varchar(255) | YES | | NULL | |
| created_at | timestamp | YES | | NULL | on update CURRENT_TIMESTAMP |
| updated_at | timestamp | YES | | NULL | on update CURRENT_TIMESTAMP |
+---------------+--------------+------+-----+---------+-----------------------------+
Use the command "desc nameTable" and paste here the return for each table.
– Giuliana Bezerra