create table fsm.state_machine ( shard_id bigint not null, id bigint not null generated by default as identity ( start with 1 cache 32767 ), statechart_id bigint not null, created_at timestamptz not null default now(), primary key (shard_id, id), constraint fk_statechart foreign key(statechart_id) references fsm.statechart(id) on delete cascade ); create index idx_statechart on fsm.state_machine(statechart_id); comment on table fsm.state_machine is 'Runtime information of a statechart. Contains state machine instances that have started.';