-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support client expressions that query 1:1 relationships
Signed-off-by: Lucian Buzzo <[email protected]>
- Loading branch information
1 parent
1fddd5d
commit 4cb0e1f
Showing
9 changed files
with
376 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...migrations/20240115145122_add_test_model_for_multi_org_permission_structure/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the column `role` on the `User` table. All the data in the column will be lost. | ||
*/ | ||
-- CreateEnum | ||
CREATE TYPE "RoleEnum" AS ENUM ('USER', 'ORGANIZATION_ADMIN', 'ADMIN'); | ||
|
||
-- AlterTable | ||
ALTER TABLE "User" DROP COLUMN "role"; | ||
|
||
-- DropEnum | ||
DROP TYPE "Role"; | ||
|
||
-- CreateTable | ||
CREATE TABLE "Organization" ( | ||
"id" SERIAL NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"name" TEXT, | ||
|
||
CONSTRAINT "Organization_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "RoleAssignment" ( | ||
"id" SERIAL NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"userId" INTEGER NOT NULL, | ||
"organizationId" INTEGER NOT NULL, | ||
"roleId" INTEGER NOT NULL, | ||
|
||
CONSTRAINT "RoleAssignment_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Role" ( | ||
"id" SERIAL NOT NULL, | ||
"name" "RoleEnum" NOT NULL, | ||
|
||
CONSTRAINT "Role_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Organization_name_key" ON "Organization"("name"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Role_name_key" ON "Role"("name"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "RoleAssignment" ADD CONSTRAINT "RoleAssignment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "RoleAssignment" ADD CONSTRAINT "RoleAssignment_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "RoleAssignment" ADD CONSTRAINT "RoleAssignment_roleId_fkey" FOREIGN KEY ("roleId") REFERENCES "Role"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
Warnings: | ||
- The primary key for the `Organization` table will be changed. If it partially fails, the table could be left without primary key constraint. | ||
- The primary key for the `Role` table will be changed. If it partially fails, the table could be left without primary key constraint. | ||
- The primary key for the `RoleAssignment` table will be changed. If it partially fails, the table could be left without primary key constraint. | ||
- The primary key for the `User` table will be changed. If it partially fails, the table could be left without primary key constraint. | ||
*/ | ||
-- DropForeignKey | ||
ALTER TABLE "Hat" DROP CONSTRAINT "Hat_userId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "Post" DROP CONSTRAINT "Post_authorId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "RoleAssignment" DROP CONSTRAINT "RoleAssignment_organizationId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "RoleAssignment" DROP CONSTRAINT "RoleAssignment_roleId_fkey"; | ||
|
||
-- DropForeignKey | ||
ALTER TABLE "RoleAssignment" DROP CONSTRAINT "RoleAssignment_userId_fkey"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "Hat" ALTER COLUMN "userId" SET DATA TYPE TEXT; | ||
|
||
-- AlterTable | ||
ALTER TABLE "Organization" DROP CONSTRAINT "Organization_pkey", | ||
ALTER COLUMN "id" DROP DEFAULT, | ||
ALTER COLUMN "id" SET DATA TYPE TEXT, | ||
ADD CONSTRAINT "Organization_pkey" PRIMARY KEY ("id"); | ||
DROP SEQUENCE "Organization_id_seq"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "Post" ALTER COLUMN "authorId" SET DATA TYPE TEXT; | ||
|
||
-- AlterTable | ||
ALTER TABLE "Role" DROP CONSTRAINT "Role_pkey", | ||
ALTER COLUMN "id" DROP DEFAULT, | ||
ALTER COLUMN "id" SET DATA TYPE TEXT, | ||
ADD CONSTRAINT "Role_pkey" PRIMARY KEY ("id"); | ||
DROP SEQUENCE "Role_id_seq"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "RoleAssignment" DROP CONSTRAINT "RoleAssignment_pkey", | ||
ALTER COLUMN "id" DROP DEFAULT, | ||
ALTER COLUMN "id" SET DATA TYPE TEXT, | ||
ALTER COLUMN "userId" SET DATA TYPE TEXT, | ||
ALTER COLUMN "organizationId" SET DATA TYPE TEXT, | ||
ALTER COLUMN "roleId" SET DATA TYPE TEXT, | ||
ADD CONSTRAINT "RoleAssignment_pkey" PRIMARY KEY ("id"); | ||
DROP SEQUENCE "RoleAssignment_id_seq"; | ||
|
||
-- AlterTable | ||
ALTER TABLE "User" DROP CONSTRAINT "User_pkey", | ||
ALTER COLUMN "id" DROP DEFAULT, | ||
ALTER COLUMN "id" SET DATA TYPE TEXT, | ||
ADD CONSTRAINT "User_pkey" PRIMARY KEY ("id"); | ||
DROP SEQUENCE "User_id_seq"; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "RoleAssignment" ADD CONSTRAINT "RoleAssignment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "RoleAssignment" ADD CONSTRAINT "RoleAssignment_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "RoleAssignment" ADD CONSTRAINT "RoleAssignment_roleId_fkey" FOREIGN KEY ("roleId") REFERENCES "Role"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Post" ADD CONSTRAINT "Post_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Hat" ADD CONSTRAINT "Hat_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; |
15 changes: 15 additions & 0 deletions
15
prisma/migrations/20240115154022_drop_role_enum/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
Warnings: | ||
- Changed the type of `name` on the `Role` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required. | ||
*/ | ||
-- AlterTable | ||
ALTER TABLE "Role" DROP COLUMN "name", | ||
ADD COLUMN "name" TEXT NOT NULL; | ||
|
||
-- DropEnum | ||
DROP TYPE "RoleEnum"; | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Role_name_key" ON "Role"("name"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.