I have two tables in MySQL 5.7 where:
- The field "id_guia" is primary key in one of them and a foreign key in another.
- The value of the field is an integer with fixed length of 11 integer characters that mean the current date plus three autoincrement integer characters (eg. 20220521001)
- In both of the tables the field "id_guia" is BIGINT(20).
- In the table where "id_guia" is primary key I can insert a row without any problem.
- In the second table where "id_guia" is a foreign key I receive the following error:
**
SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column 'id_guia' at row 1 (SQL: insert into
r_product(id_guia,id_product,peso,created_at,updated_at) values (20220521003, 1, 100, 2022-05-21 15:27:08, 2022-05-21 15:27:08))"
**
Considering that bigint(20) can go from -9223372036854775807 to 9223372036854775807, and being unsigned can go from 0 to 18446744073709551615, thus an eleven character's integer like 20220521001 should fit in there without any problem, then what am I doing wrong?
Seems somehow that I've overflown the capabilities of Mysql 5.7. The solution for this problem was to abandon MySQL 5.7 and migrating to a MySQL 8 DBMS where my code worked perfectly as it should.