+
diff --git a/lib/auth.ts b/lib/auth.ts
index e88d1f7..80ea54d 100644
--- a/lib/auth.ts
+++ b/lib/auth.ts
@@ -1,27 +1,27 @@
import { PrismaAdapter } from '@next-auth/prisma-adapter';
-import NextAuth from 'next-auth';
+import NextAuth, { DefaultSession } from 'next-auth';
import Google from 'next-auth/providers/google';
import { prisma } from '@/lib/prisma';
+declare module '../node_modules/.pnpm/@auth+core@0.0.0-manual.e9863699/node_modules/@auth/core/types.d.ts' {
+ interface Session {
+ user: {
+ id: string;
+ } & DefaultSession['user'];
+ }
+}
+
export const { auth, signIn, signOut, handlers } = NextAuth({
// pages: {
// signIn: '/login',
// error: '/auth/error'
// },
providers: [Google],
- adapter: PrismaAdapter(prisma)
- // callbacks: {
- // session: ({ session, token, user, }) => {
- // console.log({session, token, user});
- // return {
- // ...session,
- // user: {
- // ...session.user,
- // id: token.id,
- // randomKey: token.randomKey
- // }
- // };
- // }
- // }
+ adapter: PrismaAdapter(prisma),
+ callbacks: {
+ session: ({ session, user }) => {
+ return { ...session, user };
+ }
+ }
});
diff --git a/lib/prisma.ts b/lib/prisma.ts
index ccc4dcc..cadd006 100644
--- a/lib/prisma.ts
+++ b/lib/prisma.ts
@@ -1,7 +1,17 @@
import { PrismaClient } from '@prisma/client';
-// export const prisma = new PrismaClient({
-// log: ['query']
-// });
+const prismaClientSingleton = () => {
+ return new PrismaClient();
+};
-export const prisma = new PrismaClient();
+type PrismaClientSingleton = ReturnType
;
+
+const globalForPrisma = globalThis as unknown as {
+ prisma: PrismaClientSingleton | undefined;
+};
+
+export const prisma = globalForPrisma.prisma ?? prismaClientSingleton();
+
+if (process.env.NODE_ENV !== 'production') {
+ globalForPrisma.prisma = prisma;
+}
diff --git a/notes.md b/notes.md
index 494ab74..72d7d26 100644
--- a/notes.md
+++ b/notes.md
@@ -1,6 +1,15 @@
- import order for eslint
https://dev.to/otamnitram/sorting-your-imports-correctly-in-react-213m
-
--- pnpm issue with prisma
+- pnpm issue with prisma
https://github.com/prisma/prisma/issues/2584#issuecomment-646414549
+
+- pnpm issue with auth types
+https://github.com/nextauthjs/next-auth/issues/6640#issuecomment-1441383198
+
+
+- prisma client issue with next dev server
+https://www.prisma.io/docs/guides/other/troubleshooting-orm/help-articles/nextjs-prisma-client-dev-practices
+
+- next js react dev server redirect issue
+https://github.com/vercel/next.js/issues/55586
diff --git a/package.json b/package.json
index 79fcd4b..863fbca 100644
--- a/package.json
+++ b/package.json
@@ -25,7 +25,7 @@
"@radix-ui/react-slot": "^1.0.2",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
- "next": "14.0.1",
+ "next": "14.0.3",
"next-auth": "5.0.0-beta.3",
"react": "^18",
"react-dom": "^18",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 0e7d423..5ee42ad 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -39,11 +39,11 @@ dependencies:
specifier: ^2.0.0
version: 2.0.0
next:
- specifier: 14.0.1
- version: 14.0.1(react-dom@18.2.0)(react@18.2.0)
+ specifier: 14.0.3
+ version: 14.0.3(react-dom@18.2.0)(react@18.2.0)
next-auth:
specifier: 5.0.0-beta.3
- version: 5.0.0-beta.3(next@14.0.1)(react@18.2.0)
+ version: 5.0.0-beta.3(next@14.0.3)(react@18.2.0)
react:
specifier: ^18
version: 18.2.0
@@ -278,11 +278,11 @@ packages:
next-auth: ^4
dependencies:
'@prisma/client': 5.6.0(prisma@5.6.0)
- next-auth: 5.0.0-beta.3(next@14.0.1)(react@18.2.0)
+ next-auth: 5.0.0-beta.3(next@14.0.3)(react@18.2.0)
dev: false
- /@next/env@14.0.1:
- resolution: {integrity: sha512-Ms8ZswqY65/YfcjrlcIwMPD7Rg/dVjdLapMcSHG26W6O67EJDF435ShW4H4LXi1xKO1oRc97tLXUpx8jpLe86A==}
+ /@next/env@14.0.3:
+ resolution: {integrity: sha512-7xRqh9nMvP5xrW4/+L0jgRRX+HoNRGnfJpD+5Wq6/13j3dsdzxO3BCXn7D3hMqsDb+vjZnJq+vI7+EtgrYZTeA==}
dev: false
/@next/eslint-plugin-next@14.0.1:
@@ -291,8 +291,8 @@ packages:
glob: 7.1.7
dev: true
- /@next/swc-darwin-arm64@14.0.1:
- resolution: {integrity: sha512-JyxnGCS4qT67hdOKQ0CkgFTp+PXub5W1wsGvIq98TNbF3YEIN7iDekYhYsZzc8Ov0pWEsghQt+tANdidITCLaw==}
+ /@next/swc-darwin-arm64@14.0.3:
+ resolution: {integrity: sha512-64JbSvi3nbbcEtyitNn2LEDS/hcleAFpHdykpcnrstITFlzFgB/bW0ER5/SJJwUPj+ZPY+z3e+1jAfcczRLVGw==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [darwin]
@@ -300,8 +300,8 @@ packages:
dev: false
optional: true
- /@next/swc-darwin-x64@14.0.1:
- resolution: {integrity: sha512-625Z7bb5AyIzswF9hvfZWa+HTwFZw+Jn3lOBNZB87lUS0iuCYDHqk3ujuHCkiyPtSC0xFBtYDLcrZ11mF/ap3w==}
+ /@next/swc-darwin-x64@14.0.3:
+ resolution: {integrity: sha512-RkTf+KbAD0SgYdVn1XzqE/+sIxYGB7NLMZRn9I4Z24afrhUpVJx6L8hsRnIwxz3ERE2NFURNliPjJ2QNfnWicQ==}
engines: {node: '>= 10'}
cpu: [x64]
os: [darwin]
@@ -309,8 +309,8 @@ packages:
dev: false
optional: true
- /@next/swc-linux-arm64-gnu@14.0.1:
- resolution: {integrity: sha512-iVpn3KG3DprFXzVHM09kvb//4CNNXBQ9NB/pTm8LO+vnnnaObnzFdS5KM+w1okwa32xH0g8EvZIhoB3fI3mS1g==}
+ /@next/swc-linux-arm64-gnu@14.0.3:
+ resolution: {integrity: sha512-3tBWGgz7M9RKLO6sPWC6c4pAw4geujSwQ7q7Si4d6bo0l6cLs4tmO+lnSwFp1Tm3lxwfMk0SgkJT7EdwYSJvcg==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
@@ -318,8 +318,8 @@ packages:
dev: false
optional: true
- /@next/swc-linux-arm64-musl@14.0.1:
- resolution: {integrity: sha512-mVsGyMxTLWZXyD5sen6kGOTYVOO67lZjLApIj/JsTEEohDDt1im2nkspzfV5MvhfS7diDw6Rp/xvAQaWZTv1Ww==}
+ /@next/swc-linux-arm64-musl@14.0.3:
+ resolution: {integrity: sha512-v0v8Kb8j8T23jvVUWZeA2D8+izWspeyeDGNaT2/mTHWp7+37fiNfL8bmBWiOmeumXkacM/AB0XOUQvEbncSnHA==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
@@ -327,8 +327,8 @@ packages:
dev: false
optional: true
- /@next/swc-linux-x64-gnu@14.0.1:
- resolution: {integrity: sha512-wMqf90uDWN001NqCM/auRl3+qVVeKfjJdT9XW+RMIOf+rhUzadmYJu++tp2y+hUbb6GTRhT+VjQzcgg/QTD9NQ==}
+ /@next/swc-linux-x64-gnu@14.0.3:
+ resolution: {integrity: sha512-VM1aE1tJKLBwMGtyBR21yy+STfl0MapMQnNrXkxeyLs0GFv/kZqXS5Jw/TQ3TSUnbv0QPDf/X8sDXuMtSgG6eg==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
@@ -336,8 +336,8 @@ packages:
dev: false
optional: true
- /@next/swc-linux-x64-musl@14.0.1:
- resolution: {integrity: sha512-ol1X1e24w4j4QwdeNjfX0f+Nza25n+ymY0T2frTyalVczUmzkVD7QGgPTZMHfR1aLrO69hBs0G3QBYaj22J5GQ==}
+ /@next/swc-linux-x64-musl@14.0.3:
+ resolution: {integrity: sha512-64EnmKy18MYFL5CzLaSuUn561hbO1Gk16jM/KHznYP3iCIfF9e3yULtHaMy0D8zbHfxset9LTOv6cuYKJgcOxg==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
@@ -345,8 +345,8 @@ packages:
dev: false
optional: true
- /@next/swc-win32-arm64-msvc@14.0.1:
- resolution: {integrity: sha512-WEmTEeWs6yRUEnUlahTgvZteh5RJc4sEjCQIodJlZZ5/VJwVP8p2L7l6VhzQhT4h7KvLx/Ed4UViBdne6zpIsw==}
+ /@next/swc-win32-arm64-msvc@14.0.3:
+ resolution: {integrity: sha512-WRDp8QrmsL1bbGtsh5GqQ/KWulmrnMBgbnb+59qNTW1kVi1nG/2ndZLkcbs2GX7NpFLlToLRMWSQXmPzQm4tog==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [win32]
@@ -354,8 +354,8 @@ packages:
dev: false
optional: true
- /@next/swc-win32-ia32-msvc@14.0.1:
- resolution: {integrity: sha512-oFpHphN4ygAgZUKjzga7SoH2VGbEJXZa/KL8bHCAwCjDWle6R1SpiGOdUdA8EJ9YsG1TYWpzY6FTbUA+iAJeww==}
+ /@next/swc-win32-ia32-msvc@14.0.3:
+ resolution: {integrity: sha512-EKffQeqCrj+t6qFFhIFTRoqb2QwX1mU7iTOvMyLbYw3QtqTw9sMwjykyiMlZlrfm2a4fA84+/aeW+PMg1MjuTg==}
engines: {node: '>= 10'}
cpu: [ia32]
os: [win32]
@@ -363,8 +363,8 @@ packages:
dev: false
optional: true
- /@next/swc-win32-x64-msvc@14.0.1:
- resolution: {integrity: sha512-FFp3nOJ/5qSpeWT0BZQ+YE1pSMk4IMpkME/1DwKBwhg4mJLB9L+6EXuJi4JEwaJdl5iN+UUlmUD3IsR1kx5fAg==}
+ /@next/swc-win32-x64-msvc@14.0.3:
+ resolution: {integrity: sha512-ERhKPSJ1vQrPiwrs15Pjz/rvDHZmkmvbf/BjPN/UCOI++ODftT0GtasDPi0j+y6PPJi5HsXw+dpRaXUaw4vjuQ==}
engines: {node: '>= 10'}
cpu: [x64]
os: [win32]
@@ -2727,7 +2727,7 @@ packages:
resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==}
dev: true
- /next-auth@5.0.0-beta.3(next@14.0.1)(react@18.2.0):
+ /next-auth@5.0.0-beta.3(next@14.0.3)(react@18.2.0):
resolution: {integrity: sha512-WOKhATBFGeONV+29HzFmspNmL7NXxrsCWLfaDKmAd/4DD1nqXE0BzNFH8t3SJBx7PUDMnB6F7xB76LM/AaV1MQ==}
peerDependencies:
next: ^14
@@ -2738,12 +2738,12 @@ packages:
optional: true
dependencies:
'@auth/core': 0.0.0-manual.e9863699
- next: 14.0.1(react-dom@18.2.0)(react@18.2.0)
+ next: 14.0.3(react-dom@18.2.0)(react@18.2.0)
react: 18.2.0
dev: false
- /next@14.0.1(react-dom@18.2.0)(react@18.2.0):
- resolution: {integrity: sha512-s4YaLpE4b0gmb3ggtmpmV+wt+lPRuGtANzojMQ2+gmBpgX9w5fTbjsy6dXByBuENsdCX5pukZH/GxdFgO62+pA==}
+ /next@14.0.3(react-dom@18.2.0)(react@18.2.0):
+ resolution: {integrity: sha512-AbYdRNfImBr3XGtvnwOxq8ekVCwbFTv/UJoLwmaX89nk9i051AEY4/HAWzU0YpaTDw8IofUpmuIlvzWF13jxIw==}
engines: {node: '>=18.17.0'}
hasBin: true
peerDependencies:
@@ -2757,7 +2757,7 @@ packages:
sass:
optional: true
dependencies:
- '@next/env': 14.0.1
+ '@next/env': 14.0.3
'@swc/helpers': 0.5.2
busboy: 1.6.0
caniuse-lite: 1.0.30001561
@@ -2767,15 +2767,15 @@ packages:
styled-jsx: 5.1.1(react@18.2.0)
watchpack: 2.4.0
optionalDependencies:
- '@next/swc-darwin-arm64': 14.0.1
- '@next/swc-darwin-x64': 14.0.1
- '@next/swc-linux-arm64-gnu': 14.0.1
- '@next/swc-linux-arm64-musl': 14.0.1
- '@next/swc-linux-x64-gnu': 14.0.1
- '@next/swc-linux-x64-musl': 14.0.1
- '@next/swc-win32-arm64-msvc': 14.0.1
- '@next/swc-win32-ia32-msvc': 14.0.1
- '@next/swc-win32-x64-msvc': 14.0.1
+ '@next/swc-darwin-arm64': 14.0.3
+ '@next/swc-darwin-x64': 14.0.3
+ '@next/swc-linux-arm64-gnu': 14.0.3
+ '@next/swc-linux-arm64-musl': 14.0.3
+ '@next/swc-linux-x64-gnu': 14.0.3
+ '@next/swc-linux-x64-musl': 14.0.3
+ '@next/swc-win32-arm64-msvc': 14.0.3
+ '@next/swc-win32-ia32-msvc': 14.0.3
+ '@next/swc-win32-x64-msvc': 14.0.3
transitivePeerDependencies:
- '@babel/core'
- babel-plugin-macros
diff --git a/prisma/migrations/20231126110633_spaces/migration.sql b/prisma/migrations/20231126110633_spaces/migration.sql
new file mode 100644
index 0000000..8fd515b
--- /dev/null
+++ b/prisma/migrations/20231126110633_spaces/migration.sql
@@ -0,0 +1,48 @@
+/*
+ Warnings:
+
+ - You are about to drop the `UserGroup` table. If the table is not empty, all the data it contains will be lost.
+ - You are about to drop the `_UserToUserGroup` table. If the table is not empty, all the data it contains will be lost.
+
+*/
+-- DropForeignKey
+ALTER TABLE "_UserToUserGroup" DROP CONSTRAINT "_UserToUserGroup_A_fkey";
+
+-- DropForeignKey
+ALTER TABLE "_UserToUserGroup" DROP CONSTRAINT "_UserToUserGroup_B_fkey";
+
+-- DropTable
+DROP TABLE "UserGroup";
+
+-- DropTable
+DROP TABLE "_UserToUserGroup";
+
+-- CreateTable
+CREATE TABLE "Spaces" (
+ "id" SERIAL NOT NULL,
+ "name" TEXT NOT NULL,
+ "userId" TEXT NOT NULL,
+
+ CONSTRAINT "Spaces_pkey" PRIMARY KEY ("id")
+);
+
+-- CreateTable
+CREATE TABLE "_SpacesToUser" (
+ "A" INTEGER NOT NULL,
+ "B" TEXT NOT NULL
+);
+
+-- CreateIndex
+CREATE UNIQUE INDEX "_SpacesToUser_AB_unique" ON "_SpacesToUser"("A", "B");
+
+-- CreateIndex
+CREATE INDEX "_SpacesToUser_B_index" ON "_SpacesToUser"("B");
+
+-- AddForeignKey
+ALTER TABLE "Spaces" ADD CONSTRAINT "Spaces_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "_SpacesToUser" ADD CONSTRAINT "_SpacesToUser_A_fkey" FOREIGN KEY ("A") REFERENCES "Spaces"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "_SpacesToUser" ADD CONSTRAINT "_SpacesToUser_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
diff --git a/prisma/migrations/20231126110936_change_field_to_admin_id/migration.sql b/prisma/migrations/20231126110936_change_field_to_admin_id/migration.sql
new file mode 100644
index 0000000..1cea256
--- /dev/null
+++ b/prisma/migrations/20231126110936_change_field_to_admin_id/migration.sql
@@ -0,0 +1,16 @@
+/*
+ Warnings:
+
+ - You are about to drop the column `userId` on the `Spaces` table. All the data in the column will be lost.
+ - Added the required column `adminId` to the `Spaces` table without a default value. This is not possible if the table is not empty.
+
+*/
+-- DropForeignKey
+ALTER TABLE "Spaces" DROP CONSTRAINT "Spaces_userId_fkey";
+
+-- AlterTable
+ALTER TABLE "Spaces" DROP COLUMN "userId",
+ADD COLUMN "adminId" TEXT NOT NULL;
+
+-- AddForeignKey
+ALTER TABLE "Spaces" ADD CONSTRAINT "Spaces_adminId_fkey" FOREIGN KEY ("adminId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
diff --git a/prisma/migrations/20231126111343_remove_admin/migration.sql b/prisma/migrations/20231126111343_remove_admin/migration.sql
new file mode 100644
index 0000000..2064c9c
--- /dev/null
+++ b/prisma/migrations/20231126111343_remove_admin/migration.sql
@@ -0,0 +1,11 @@
+/*
+ Warnings:
+
+ - You are about to drop the column `adminId` on the `Spaces` table. All the data in the column will be lost.
+
+*/
+-- DropForeignKey
+ALTER TABLE "Spaces" DROP CONSTRAINT "Spaces_adminId_fkey";
+
+-- AlterTable
+ALTER TABLE "Spaces" DROP COLUMN "adminId";
diff --git a/prisma/migrations/20231126112121_spaces_typo/migration.sql b/prisma/migrations/20231126112121_spaces_typo/migration.sql
new file mode 100644
index 0000000..3a6b406
--- /dev/null
+++ b/prisma/migrations/20231126112121_spaces_typo/migration.sql
@@ -0,0 +1,44 @@
+/*
+ Warnings:
+
+ - You are about to drop the `Spaces` table. If the table is not empty, all the data it contains will be lost.
+ - You are about to drop the `_SpacesToUser` table. If the table is not empty, all the data it contains will be lost.
+
+*/
+-- DropForeignKey
+ALTER TABLE "_SpacesToUser" DROP CONSTRAINT "_SpacesToUser_A_fkey";
+
+-- DropForeignKey
+ALTER TABLE "_SpacesToUser" DROP CONSTRAINT "_SpacesToUser_B_fkey";
+
+-- DropTable
+DROP TABLE "Spaces";
+
+-- DropTable
+DROP TABLE "_SpacesToUser";
+
+-- CreateTable
+CREATE TABLE "Space" (
+ "id" SERIAL NOT NULL,
+ "name" TEXT NOT NULL,
+
+ CONSTRAINT "Space_pkey" PRIMARY KEY ("id")
+);
+
+-- CreateTable
+CREATE TABLE "_SpaceToUser" (
+ "A" INTEGER NOT NULL,
+ "B" TEXT NOT NULL
+);
+
+-- CreateIndex
+CREATE UNIQUE INDEX "_SpaceToUser_AB_unique" ON "_SpaceToUser"("A", "B");
+
+-- CreateIndex
+CREATE INDEX "_SpaceToUser_B_index" ON "_SpaceToUser"("B");
+
+-- AddForeignKey
+ALTER TABLE "_SpaceToUser" ADD CONSTRAINT "_SpaceToUser_A_fkey" FOREIGN KEY ("A") REFERENCES "Space"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "_SpaceToUser" ADD CONSTRAINT "_SpaceToUser_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
diff --git a/prisma/migrations/20231126205230_update_space_schema/migration.sql b/prisma/migrations/20231126205230_update_space_schema/migration.sql
new file mode 100644
index 0000000..a90fd95
--- /dev/null
+++ b/prisma/migrations/20231126205230_update_space_schema/migration.sql
@@ -0,0 +1,28 @@
+/*
+ Warnings:
+
+ - You are about to drop the `_SpaceToUser` table. If the table is not empty, all the data it contains will be lost.
+ - A unique constraint covering the columns `[creatorId,name]` on the table `Space` will be added. If there are existing duplicate values, this will fail.
+ - Added the required column `creatorId` to the `Space` table without a default value. This is not possible if the table is not empty.
+ - Added the required column `updatedAt` to the `Space` table without a default value. This is not possible if the table is not empty.
+
+*/
+-- DropForeignKey
+ALTER TABLE "_SpaceToUser" DROP CONSTRAINT "_SpaceToUser_A_fkey";
+
+-- DropForeignKey
+ALTER TABLE "_SpaceToUser" DROP CONSTRAINT "_SpaceToUser_B_fkey";
+
+-- AlterTable
+ALTER TABLE "Space" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ADD COLUMN "creatorId" TEXT NOT NULL,
+ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL;
+
+-- DropTable
+DROP TABLE "_SpaceToUser";
+
+-- CreateIndex
+CREATE UNIQUE INDEX "Space_creatorId_name_key" ON "Space"("creatorId", "name");
+
+-- AddForeignKey
+ALTER TABLE "Space" ADD CONSTRAINT "Space_creatorId_fkey" FOREIGN KEY ("creatorId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
diff --git a/prisma/migrations/20231203104403_make_space_unique/migration.sql b/prisma/migrations/20231203104403_make_space_unique/migration.sql
new file mode 100644
index 0000000..b51981f
--- /dev/null
+++ b/prisma/migrations/20231203104403_make_space_unique/migration.sql
@@ -0,0 +1,8 @@
+/*
+ Warnings:
+
+ - A unique constraint covering the columns `[name]` on the table `Space` will be added. If there are existing duplicate values, this will fail.
+
+*/
+-- CreateIndex
+CREATE UNIQUE INDEX "Space_name_key" ON "Space"("name");
diff --git a/prisma/migrations/20231203104908_y/migration.sql b/prisma/migrations/20231203104908_y/migration.sql
new file mode 100644
index 0000000..e6035e2
--- /dev/null
+++ b/prisma/migrations/20231203104908_y/migration.sql
@@ -0,0 +1,15 @@
+/*
+ Warnings:
+
+ - The primary key for the `Space` table will be changed. If it partially fails, the table could be left without primary key constraint.
+
+*/
+-- DropIndex
+DROP INDEX "Space_name_key";
+
+-- AlterTable
+ALTER TABLE "Space" DROP CONSTRAINT "Space_pkey",
+ALTER COLUMN "id" DROP DEFAULT,
+ALTER COLUMN "id" SET DATA TYPE TEXT,
+ADD CONSTRAINT "Space_pkey" PRIMARY KEY ("id");
+DROP SEQUENCE "Space_id_seq";
diff --git a/prisma/migrations/20231203122846_add_lists/migration.sql b/prisma/migrations/20231203122846_add_lists/migration.sql
new file mode 100644
index 0000000..fa268a2
--- /dev/null
+++ b/prisma/migrations/20231203122846_add_lists/migration.sql
@@ -0,0 +1,17 @@
+-- CreateTable
+CREATE TABLE "List" (
+ "id" TEXT NOT NULL,
+ "name" TEXT NOT NULL,
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ "updatedAt" TIMESTAMP(3) NOT NULL,
+ "spaceId" TEXT NOT NULL,
+ "creatorId" TEXT NOT NULL,
+
+ CONSTRAINT "List_pkey" PRIMARY KEY ("id")
+);
+
+-- AddForeignKey
+ALTER TABLE "List" ADD CONSTRAINT "List_spaceId_fkey" FOREIGN KEY ("spaceId") REFERENCES "Space"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
+
+-- AddForeignKey
+ALTER TABLE "List" ADD CONSTRAINT "List_creatorId_fkey" FOREIGN KEY ("creatorId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
diff --git a/prisma/migrations/20231203125043_list_to_lists/migration.sql b/prisma/migrations/20231203125043_list_to_lists/migration.sql
new file mode 100644
index 0000000..ae2b70f
--- /dev/null
+++ b/prisma/migrations/20231203125043_list_to_lists/migration.sql
@@ -0,0 +1,8 @@
+/*
+ Warnings:
+
+ - Added the required column `favorite` to the `List` table without a default value. This is not possible if the table is not empty.
+
+*/
+-- AlterTable
+ALTER TABLE "List" ADD COLUMN "favorite" BOOLEAN NOT NULL;
diff --git a/prisma/migrations/20231203163928_make_favorite_optional/migration.sql b/prisma/migrations/20231203163928_make_favorite_optional/migration.sql
new file mode 100644
index 0000000..0bc61db
--- /dev/null
+++ b/prisma/migrations/20231203163928_make_favorite_optional/migration.sql
@@ -0,0 +1,12 @@
+/*
+ Warnings:
+
+ - A unique constraint covering the columns `[creatorId,name,spaceId]` on the table `List` will be added. If there are existing duplicate values, this will fail.
+
+*/
+-- AlterTable
+ALTER TABLE "List" ALTER COLUMN "favorite" DROP NOT NULL,
+ALTER COLUMN "favorite" SET DEFAULT false;
+
+-- CreateIndex
+CREATE UNIQUE INDEX "List_creatorId_name_spaceId_key" ON "List"("creatorId", "name", "spaceId");
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index 886c143..e2ce7cf 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -38,14 +38,15 @@ model Session {
}
model User {
- id String @id @default(cuid())
+ id String @id @default(cuid())
name String?
- email String? @unique
+ email String? @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
- UserGroup UserGroup[]
+ spaces Space[]
+ Lists List[]
}
model VerificationToken {
@@ -56,14 +57,33 @@ model VerificationToken {
@@unique([identifier, token])
}
-model UserGroup {
- id Int @id @default(autoincrement())
+model Space {
+ id String @id @default(cuid())
name String
- users User[]
+ Lists List[]
+
+ createdAt DateTime @default(now())
+ updatedAt DateTime @updatedAt
+
+ creator User @relation(fields: [creatorId], references: [id])
+ creatorId String
+
+ @@unique([creatorId, name], name: "SpaceIdentifier")
}
-// model Expense {
-// id Int @id @default(autoincrement())
-// name String
-// price
-// }
+model List {
+ id String @id @default(cuid())
+ name String
+ favorite Boolean? @default(false)
+
+ createdAt DateTime @default(now())
+ updatedAt DateTime @updatedAt
+
+ Space Space @relation(fields: [spaceId], references: [id])
+ spaceId String
+
+ creator User @relation(fields: [creatorId], references: [id])
+ creatorId String
+
+ @@unique([creatorId, name, spaceId], name: "ListIdentifier")
+}
diff --git a/todo.md b/todo.md
index f6e7250..d20e595 100644
--- a/todo.md
+++ b/todo.md
@@ -1,2 +1,5 @@
-- handle session issue
-- fix ui for google auth
+## Second Iteration
+- get rid of useraccout dropdown
+
+## Animations
+