♻️ Switch to turborepo (#532)

This commit is contained in:
Luke Vella 2023-03-01 14:10:06 +00:00 committed by GitHub
parent 41ef81aa75
commit 0a836aeec7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
419 changed files with 2300 additions and 2504 deletions

View file

@ -0,0 +1,43 @@
-- AlterTable
ALTER TABLE "Comment" ADD COLUMN "updatedAt" TIMESTAMP(3);
-- AlterTable
ALTER TABLE "Option" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "updatedAt" TIMESTAMP(3);
-- AlterTable
ALTER TABLE "Participant" ADD COLUMN "updatedAt" TIMESTAMP(3);
-- AlterTable
ALTER TABLE "User" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "updatedAt" TIMESTAMP(3);
-- AlterTable
ALTER TABLE "Vote" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "updatedAt" TIMESTAMP(3);
-- We need to get rid of duplicate email addresses in the users table
-- because the index was previously case sensitive
-- First we update all polls created by users with a duplicate email address
-- to a single user
UPDATE "Poll" p SET "userId" = u.id
FROM (
SELECT min(id) id, array_agg(id) as "userIds"
FROM "User" u
GROUP BY lower(email)
HAVING count(*) > 1
) u
WHERE p."userId" = any(u."userIds")
AND p."userId" <> u.id;
-- Remove all users that do not have polls
DELETE FROM "User" u
WHERE NOT EXISTS (SELECT * FROM "Poll" p WHERE u.id = p."userId");
-- Add citext extension
CREATE EXTENSION IF NOT EXISTS citext;
-- Change email to citext
ALTER TABLE "User"
ALTER COLUMN email TYPE citext;