failed to generate code by goctl with ddl #2146
-
I wrote an init.sql: CREATE database if not exists blog default charset utf8mb4 collate utf8MB4_general_ci;
use blog;
CREATE TABLE post
(
id bigint auto_increment primary key NOT NULL,
title varchar(255) NOT NULL,
draft boolean NOT NULL,
content text not null,
filename varchar(255) NOT NULL,
md5 CHAR(32) NOT NULL,
created_date date not null,
created_time time not null,
updated_date date not null,
updated_time time not null
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4;
CREATE TABLE tag
(
id bigint auto_increment PRIMARY KEY NOT NULL,
tag varchar(255) NOT NULL,
created_date date not null,
created_time time not null,
updated_date date not null,
updated_time time not null
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4;
CREATE TABLE category
(
id bigint auto_increment PRIMARY KEY NOT NULL,
category varchar(255) NOT NULL,
created_date date not null,
created_time time not null,
updated_date date not null,
updated_time time not null
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4;
CREATE TABLE article
(
id bigint auto_increment PRIMARY KEY NOT NULL,
post_id bigint NOT NULL,
created_date date not null,
created_time time not null,
updated_date date not null,
updated_time time not null
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4;
CREATE TABLE rel_post_tag
(
id bigint auto_increment PRIMARY KEY NOT NULL,
post_id bigint NOT NULL,
tag_id bigint NOT NULL,
state int NOT NULL default 0,
created_date date not null,
created_time time not null,
updated_date date not null,
updated_time time not null
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4;
CREATE TABLE rel_post_category
(
id bigint auto_increment PRIMARY KEY NOT NULL,
post_id bigint NOT NULL,
category_id bigint NOT NULL,
state int NOT NULL default 0,
created_date date not null,
created_time time not null,
updated_date date not null,
updated_time time not null
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4; And then I execute
Can someone tell me where is the wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
if your fields have a |
Beta Was this translation helpful? Give feedback.
-
goctl can't match the |
Beta Was this translation helpful? Give feedback.
goctl can't match the
primary key
keyword in the column definition. It worked when I used theprimary key (id)