In the PostgreSQL database, the item table is defined
CREATE TABLE item
(
"objectId" text NOT NULL,
"createdAt" timestamp with time zone,
"updatedAt" timestamp with time zone,
_rperm text[],
_wperm text[],
item_name text,
item_id integer,
CONSTRAINT "ITEM_pkey" PRIMARY KEY ("objectId")
)
WITH (
OIDS=FALSE
);
ALTER TABLE item
OWNER TO gc;
I would like to create a trigger on this table. When a new record is being inserted (not updated), the item_id column should have the maximum value of all existing item_id values plus 1. This is mimicing the auto-incrementing behaviour on item_id.
item_idwith this approach. is that acceptable?serial(or identity) using a sequence is the only sane, performant and scalable solution to create unique numbers.