fix diff round-trip comparison

This commit is contained in:
SG Command
2026-08-31 02:05:32 +02:00
parent 098e927760
commit e8ac0e8c35
8 changed files with 275 additions and 30 deletions
+30
View File
@@ -0,0 +1,30 @@
CREATE TABLE public.users (
id integer NOT NULL,
username varchar(255) NOT NULL,
email varchar(255) NOT NULL,
created_at timestamptz NOT NULL,
profile_id integer
);
CREATE TABLE public.profiles (
id integer NOT NULL,
bio text,
created_at timestamptz NOT NULL
);
CREATE TABLE public.posts (
id integer NOT NULL,
user_id integer NOT NULL,
title varchar(255) NOT NULL,
body text,
published_at timestamptz,
view_count integer DEFAULT 0
);
ALTER TABLE public.users ADD PRIMARY KEY (id);
ALTER TABLE public.profiles ADD PRIMARY KEY (id);
ALTER TABLE public.posts ADD PRIMARY KEY (id);
CREATE UNIQUE INDEX posts_user_id_title_idx ON public.posts (user_id, title);
ALTER TABLE public.users ADD CONSTRAINT users_profile_id_fkey FOREIGN KEY (profile_id) REFERENCES public.profiles (id);
+28
View File
@@ -0,0 +1,28 @@
Table users {
id integer [pk, not null]
username varchar(255) [not null]
email varchar(255) [not null]
created_at timestamptz [not null]
profile_id integer
}
Table profiles {
id integer [pk, not null]
bio text
created_at timestamptz [not null]
}
Table posts {
id integer [pk, not null]
user_id integer [not null]
title varchar(255) [not null]
body text
published_at timestamptz
view_count integer default 0
Indexes {
(user_id, title) [unique]
}
}
Ref: users.profile_id > profiles.id