Create guest user in user table when creating a participant

This commit is contained in:
Luke Vella 2024-12-19 15:26:43 +00:00
parent 346ef136f0
commit 65192f95c9
No known key found for this signature in database
GPG key ID: 469CAD687F0D784C
5 changed files with 20 additions and 7 deletions

View file

@ -9,8 +9,9 @@ BEGIN
WHERE user_id IS NULL
LOOP
WITH new_user AS (
INSERT INTO users (is_guest, created_at)
INSERT INTO users (id, is_guest, created_at)
VALUES (
gen_random_uuid()::text,
TRUE,
NOW()
)

View file

@ -4,7 +4,6 @@
- Made the column `user_id` on table `participants` required. This step will fail if there are existing NULL values in that column.
*/
-- AlterTable
ALTER TABLE "participants" ALTER COLUMN "user_id" SET NOT NULL;

View file

@ -0,0 +1,5 @@
-- DropForeignKey
ALTER TABLE "participants" DROP CONSTRAINT "participants_user_id_fkey";
-- AddForeignKey
ALTER TABLE "participants" ADD CONSTRAINT "participants_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;