failed to generate code by goctl with ddl #2146
Answered
by
alexcdever
alexcdever
asked this question in
Q&A
-
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.
Answered by
alexcdever
Jul 16, 2022
Replies: 2 comments 1 reply
-
if your fields have a |
Beta Was this translation helpful? Give feedback.
1 reply
-
goctl can't match the |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
alexcdever
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
goctl can't match the
primary key
keyword in the column definition. It worked when I used theprimary key (id)