I am trying to “convert” SQL code from guide’s example into migration. The SQL code assumes non-standard primary key (i.e. char(2) not null instead of int):
CREATE TABLE `country` (
`code` CHAR(2) NOT NULL PRIMARY KEY,
`name` CHAR(52) NOT NULL,
`population` INT(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
When I am trying to “replicate” the above with migration, the following code works:
Unfortunately for me this error says pretty much nothing.
And your example code is only syntactically correct (meaning that such migrations works). But, it is semantically incorrect (meaning that the achieved result is other than expected).
Your code only differs from my code in that it creates int(2) primary key. It does not create a char(2) primary key – which is what I am trying to achieve.
I assume,
Creates integer column with specified length. It’s one of the shortcut for common type of PK column. You can use other methods for custom pk like you did already.