|
| 1 | +create table "public"."qr_code" ( |
| 2 | + "id" uuid not null default gen_random_uuid(), |
| 3 | + "short_code" text not null, |
| 4 | + "target_url" text, |
| 5 | + "qr_type" character varying, |
| 6 | + "design_settings" json, |
| 7 | + "created_at" timestamp without time zone, |
| 8 | + "scan_count" bigint, |
| 9 | + "user_id" uuid default gen_random_uuid() |
| 10 | +); |
| 11 | + |
| 12 | + |
| 13 | +alter table "public"."qr_code" enable row level security; |
| 14 | + |
| 15 | + |
| 16 | + create table "public"."scans" ( |
| 17 | + "id" uuid not null default gen_random_uuid(), |
| 18 | + "qr_id" uuid not null default auth.uid(), |
| 19 | + "scanned_at" timestamp without time zone, |
| 20 | + "device_type" character varying, |
| 21 | + "country" character varying, |
| 22 | + "ip_address" text |
| 23 | + ); |
| 24 | + |
| 25 | + |
| 26 | +alter table "public"."scans" enable row level security; |
| 27 | + |
| 28 | +CREATE UNIQUE INDEX qr_code_pkey ON public.qr_code USING btree (id); |
| 29 | + |
| 30 | +CREATE UNIQUE INDEX scans_pkey ON public.scans USING btree (id); |
| 31 | + |
| 32 | +alter table "public"."qr_code" add constraint "qr_code_pkey" PRIMARY KEY using index "qr_code_pkey"; |
| 33 | + |
| 34 | +alter table "public"."scans" add constraint "scans_pkey" PRIMARY KEY using index "scans_pkey"; |
| 35 | + |
| 36 | +alter table "public"."qr_code" add constraint "qr_code_user_id_fkey" FOREIGN KEY (user_id) REFERENCES public.users(id) ON UPDATE CASCADE ON DELETE CASCADE not valid; |
| 37 | + |
| 38 | +alter table "public"."qr_code" validate constraint "qr_code_user_id_fkey"; |
| 39 | + |
| 40 | +alter table "public"."scans" add constraint "scans_qr_id_fkey" FOREIGN KEY (qr_id) REFERENCES public.qr_code(id) ON UPDATE CASCADE ON DELETE CASCADE not valid; |
| 41 | + |
| 42 | +alter table "public"."scans" validate constraint "scans_qr_id_fkey"; |
| 43 | + |
| 44 | +grant delete on table "public"."qr_code" to "anon"; |
| 45 | + |
| 46 | +grant insert on table "public"."qr_code" to "anon"; |
| 47 | + |
| 48 | +grant references on table "public"."qr_code" to "anon"; |
| 49 | + |
| 50 | +grant select on table "public"."qr_code" to "anon"; |
| 51 | + |
| 52 | +grant trigger on table "public"."qr_code" to "anon"; |
| 53 | + |
| 54 | +grant truncate on table "public"."qr_code" to "anon"; |
| 55 | + |
| 56 | +grant update on table "public"."qr_code" to "anon"; |
| 57 | + |
| 58 | +grant delete on table "public"."qr_code" to "authenticated"; |
| 59 | + |
| 60 | +grant insert on table "public"."qr_code" to "authenticated"; |
| 61 | + |
| 62 | +grant references on table "public"."qr_code" to "authenticated"; |
| 63 | + |
| 64 | +grant select on table "public"."qr_code" to "authenticated"; |
| 65 | + |
| 66 | +grant trigger on table "public"."qr_code" to "authenticated"; |
| 67 | + |
| 68 | +grant truncate on table "public"."qr_code" to "authenticated"; |
| 69 | + |
| 70 | +grant update on table "public"."qr_code" to "authenticated"; |
| 71 | + |
| 72 | +grant delete on table "public"."qr_code" to "service_role"; |
| 73 | + |
| 74 | +grant insert on table "public"."qr_code" to "service_role"; |
| 75 | + |
| 76 | +grant references on table "public"."qr_code" to "service_role"; |
| 77 | + |
| 78 | +grant select on table "public"."qr_code" to "service_role"; |
| 79 | + |
| 80 | +grant trigger on table "public"."qr_code" to "service_role"; |
| 81 | + |
| 82 | +grant truncate on table "public"."qr_code" to "service_role"; |
| 83 | + |
| 84 | +grant update on table "public"."qr_code" to "service_role"; |
| 85 | + |
| 86 | +grant delete on table "public"."scans" to "anon"; |
| 87 | + |
| 88 | +grant insert on table "public"."scans" to "anon"; |
| 89 | + |
| 90 | +grant references on table "public"."scans" to "anon"; |
| 91 | + |
| 92 | +grant select on table "public"."scans" to "anon"; |
| 93 | + |
| 94 | +grant trigger on table "public"."scans" to "anon"; |
| 95 | + |
| 96 | +grant truncate on table "public"."scans" to "anon"; |
| 97 | + |
| 98 | +grant update on table "public"."scans" to "anon"; |
| 99 | + |
| 100 | +grant delete on table "public"."scans" to "authenticated"; |
| 101 | + |
| 102 | +grant insert on table "public"."scans" to "authenticated"; |
| 103 | + |
| 104 | +grant references on table "public"."scans" to "authenticated"; |
| 105 | + |
| 106 | +grant select on table "public"."scans" to "authenticated"; |
| 107 | + |
| 108 | +grant trigger on table "public"."scans" to "authenticated"; |
| 109 | + |
| 110 | +grant truncate on table "public"."scans" to "authenticated"; |
| 111 | + |
| 112 | +grant update on table "public"."scans" to "authenticated"; |
| 113 | + |
| 114 | +grant delete on table "public"."scans" to "service_role"; |
| 115 | + |
| 116 | +grant insert on table "public"."scans" to "service_role"; |
| 117 | + |
| 118 | +grant references on table "public"."scans" to "service_role"; |
| 119 | + |
| 120 | +grant select on table "public"."scans" to "service_role"; |
| 121 | + |
| 122 | +grant trigger on table "public"."scans" to "service_role"; |
| 123 | + |
| 124 | +grant truncate on table "public"."scans" to "service_role"; |
| 125 | + |
| 126 | +grant update on table "public"."scans" to "service_role"; |
| 127 | + |
| 128 | + |
0 commit comments