summaryrefslogtreecommitdiffstats
path: root/crates/profile-service/migrations/20250726161947_profile.sql
diff options
context:
space:
mode:
authorrtkay123 <dev@kanjala.com>2025-07-26 19:24:38 +0200
committerrtkay123 <dev@kanjala.com>2025-07-26 19:24:38 +0200
commite26d87f4fa18999c6bcfbcf32cfa85adab11acdd (patch)
tree603c6dacb6c448984bdcc5fa2b4a9314f1a23960 /crates/profile-service/migrations/20250726161947_profile.sql
parent236876f1d0539ac22a3977fd8599933725ad0f90 (diff)
downloadsellershut-e26d87f4fa18999c6bcfbcf32cfa85adab11acdd.tar.bz2
sellershut-e26d87f4fa18999c6bcfbcf32cfa85adab11acdd.zip
feat(auth): create user call
Diffstat (limited to 'crates/profile-service/migrations/20250726161947_profile.sql')
-rw-r--r--crates/profile-service/migrations/20250726161947_profile.sql32
1 files changed, 32 insertions, 0 deletions
diff --git a/crates/profile-service/migrations/20250726161947_profile.sql b/crates/profile-service/migrations/20250726161947_profile.sql
new file mode 100644
index 0000000..15822c8
--- /dev/null
+++ b/crates/profile-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();