From 3c4d17cf2840c643b8cd111ef775750cc5ae83b3 Mon Sep 17 00:00:00 2001 From: rtkay123 Date: Sun, 27 Jul 2025 18:16:41 +0200 Subject: refactor: profile -> users --- .../migrations/20250726161947_profile.sql | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 crates/users-service/migrations/20250726161947_profile.sql (limited to 'crates/users-service/migrations') diff --git a/crates/users-service/migrations/20250726161947_profile.sql b/crates/users-service/migrations/20250726161947_profile.sql new file mode 100644 index 0000000..15822c8 --- /dev/null +++ b/crates/users-service/migrations/20250726161947_profile.sql @@ -0,0 +1,32 @@ +create table profile ( + id text primary key, + username varchar(30) not null, + inbox text not null, + outbox text, + local boolean not null, + avatar_url text, + description text, + user_type text not null check ( + user_type IN ('PERSON', 'APPLICATION', 'GROUP', 'ORGANIZATION', 'SERVICE') + ), + created_at timestamptz not null default now(), + updated_at timestamptz not null default now(), + public_key text not null +); + +create unique index unique_username_local + on profile (username) + where local = true; + +create or replace function set_updated_at() +returns trigger as $$ +begin + new.updated_at := now(); + return new; +end; +$$ language plpgsql; + +create trigger trigger_set_updated_at +before update on profile +for each row +execute function set_updated_at(); -- cgit v1.2.3