СА
У CEO достаточно рычагов и аргументов, чтобы успешно выступать третьей ножкой табуретки, не будучи при этом докой в технологиях.
Size: a a a
СА
Y
SG
SG
Y
SG
E
MS
MS
K
K
KN
create table users
(
id uuid default gen_random_uuid() not null
constraint users_pkey
primary key,
name text not null,
email text not null
);
create table profile_events
(
id uuid default gen_random_uuid() not null
constraint profile_events_pkey
primary key,
userid uuid not null
constraint profile_events_userid_fkey
references users
on update restrict on delete restrict,
type text not null,
body jsonb not null,
inserted_at timestamp with time zone default now() not null
);
create materialized view profile_view as
WITH t AS (
SELECT profile_events.id,
profile_events.userid,
profile_events.type,
profile_events.body,
profile_events.inserted_at,
row_number()
OVER (PARTITION BY profile_events.userid, profile_events.type ORDER BY profile_events.inserted_at DESC) AS row_number
FROM profile_events
)
SELECT t.userid,
t.type,
t.body ->> 'name'::text AS name,
t.body ->> 'surname'::text AS surname,
t.inserted_at
FROM t
WHERE t.row_number = 1;
VI
KN
AR
KN
VI
VI
G