Replace `SERIAL` with `int GENERATED BY DEFAULT AS IDENTITY`

Don’t use SERIAL. Please add the option for PostgreSQL 10 and later.

Hi @imambungo ,
I currently have the following proposal:
For export:
Case 1: When you use data types like int, integer, smallint, and bigint for incremental configuration. It will output as “GENERATED BY DEFAULT AS IDENTITY”.
input dbml

Table "table1" {
  "id" int [pk, increment]
  "payload" text
}

output sql

CREATE TABLE "table1" (
  "id" INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
  "payload" text
);

Case 2: When you use data types like serial, bigserial, and smallserial for incremental configuration. It will output the same type.
input dbml

Table “table5” {
“id” serial [pk, increment]
“name” varchar
}

output sql

CREATE TABLE "table5" (
  "id" SERIAL PRIMARY KEY,
  "name" varchar
);

case 3: for all remaining data with incremental setting, it will output with serial data type.

Can you give me more of your opinion?
Thank you!

I’m totally fine with that. I think that’s a good solution.

1 Like