Skip to content

Commit 55318a3

Browse files
committed
feat: added new chat record system
1 parent a29f0ac commit 55318a3

9 files changed

Lines changed: 52 additions & 0 deletions

File tree

metadata/tables.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3169,6 +3169,10 @@
31693169
- table:
31703170
name: member_chat_record
31713171
schema: public
3172+
object_relationships:
3173+
- name: user
3174+
using:
3175+
foreign_key_constraint_on: user_id
31723176
- table:
31733177
name: mentor_application
31743178
schema: public
@@ -3251,6 +3255,13 @@
32513255
_eq: X-Hasura-User-Id
32523256
- to_uuid:
32533257
_eq: X-Hasura-User-Id
3258+
- table:
3259+
name: mentor_talk_record
3260+
schema: public
3261+
object_relationships:
3262+
- name: user
3263+
using:
3264+
foreign_key_constraint_on: user_id
32543265
- table:
32553266
name: mentor_time
32563267
schema: public
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
alter table "public"."member_chat_record" drop constraint "member_chat_record_user_id_fkey",
2+
add constraint "member_chat_record_id_fkey"
3+
foreign key ("id")
4+
references "public"."users"
5+
("uuid") on update cascade on delete cascade;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
alter table "public"."member_chat_record" drop constraint "member_chat_record_id_fkey",
2+
add constraint "member_chat_record_user_id_fkey"
3+
foreign key ("user_id")
4+
references "public"."users"
5+
("uuid") on update cascade on delete cascade;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
alter table "public"."member_chat_record"
2+
add constraint "member_chat_record_user_id_fkey"
3+
foreign key ("user_id")
4+
references "public"."users"
5+
("uuid") on update cascade on delete cascade;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
alter table "public"."member_chat_record" drop constraint "member_chat_record_user_id_fkey";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
alter table "public"."member_chat_record" drop constraint "member_chat_record_user_id_fkey";
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
alter table "public"."member_chat_record"
2+
add constraint "member_chat_record_user_id_fkey"
3+
foreign key ("user_id")
4+
references "public"."users"
5+
("uuid") on update cascade on delete cascade;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DROP TABLE "public"."mentor_talk_record";
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
CREATE TABLE "public"."mentor_talk_record" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "updated_at" timestamptz NOT NULL DEFAULT now(), "user_id" uuid NOT NULL, "semester" text NOT NULL, "mentor_talk_confirm" boolean NOT NULL DEFAULT false, PRIMARY KEY ("id") , FOREIGN KEY ("user_id") REFERENCES "public"."users"("uuid") ON UPDATE cascade ON DELETE cascade, UNIQUE ("id"));
2+
CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()
3+
RETURNS TRIGGER AS $$
4+
DECLARE
5+
_new record;
6+
BEGIN
7+
_new := NEW;
8+
_new."updated_at" = NOW();
9+
RETURN _new;
10+
END;
11+
$$ LANGUAGE plpgsql;
12+
CREATE TRIGGER "set_public_mentor_talk_record_updated_at"
13+
BEFORE UPDATE ON "public"."mentor_talk_record"
14+
FOR EACH ROW
15+
EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();
16+
COMMENT ON TRIGGER "set_public_mentor_talk_record_updated_at" ON "public"."mentor_talk_record"
17+
IS 'trigger to set value of column "updated_at" to current timestamp on row update';
18+
CREATE EXTENSION IF NOT EXISTS pgcrypto;

0 commit comments

Comments
 (0)