Skip to content

Commit

Permalink
Fix stage deletion by removing unused tables (#697)
Browse files Browse the repository at this point in the history
* Drop action_claim and action_move tables

These tables aren't used by our code anymore and were originally intended
to keep a history of claims and moves on a pub. Since we're not doing that
currently I have removed both tables to avoid any confusion

* Define some missing cascading behavior

* Generate migration/types
  • Loading branch information
kalilsn authored Oct 9, 2024
1 parent b08ed69 commit 5d75b1f
Show file tree
Hide file tree
Showing 11 changed files with 265 additions and 646 deletions.
4 changes: 0 additions & 4 deletions core/app/c/[communitySlug]/pubs/[pubId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import Assign from "~/app/c/[communitySlug]/stages/components/Assign";
import Move from "~/app/c/[communitySlug]/stages/components/Move";
import { PubsRunActionDropDownMenu } from "~/app/components/ActionUI/PubsRunActionDropDownMenu";
import IntegrationActions from "~/app/components/IntegrationActions";
import MembersAvatars from "~/app/components/MemberAvatar";
import { CreatePubButton } from "~/app/components/pubs/CreatePubButton";
import { PubTitle } from "~/app/components/PubTitle";
import SkeletonTable from "~/app/components/skeletons/SkeletonTable";
Expand Down Expand Up @@ -154,9 +153,6 @@ export default async function Page({
) : null}
</div>
</div>
<div>
<MembersAvatars pub={pub} />
</div>
<div>
<div className="mb-1 text-lg font-bold">Integrations</div>
<div>
Expand Down
31 changes: 0 additions & 31 deletions core/app/components/MemberAvatar.tsx

This file was deleted.

1 change: 0 additions & 1 deletion core/app/components/__tests__/PubTitle.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ test("PubTitle component includes the pub title", async () => {
},
],
integrationInstances: [],
claims: [],
children: [],
permissions: [],
};
Expand Down
1 change: 0 additions & 1 deletion core/lib/server/_legacy-integration-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ export const pubInclude = {
},
},
integrationInstances: { include: { integration: true } },
claims: { include: { user: true } },
children: {
...makeRecursiveInclude(
"children",
Expand Down
8 changes: 0 additions & 8 deletions core/prisma/comments/.comments-lock
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,6 @@ COMMENT ON COLUMN "PubFieldSchema"."schema" IS '@type(JSONSchemaType<any>, ''ajv



-- Model action_claim comments



-- Model action_move comments



-- Model members comments


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
Warnings:
- You are about to drop the `action_claim` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `action_move` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "action_claim" DROP CONSTRAINT "action_claim_pubId_fkey";

-- DropForeignKey
ALTER TABLE "action_claim" DROP CONSTRAINT "action_claim_stageId_fkey";

-- DropForeignKey
ALTER TABLE "action_claim" DROP CONSTRAINT "action_claim_userId_fkey";

-- DropForeignKey
ALTER TABLE "action_move" DROP CONSTRAINT "action_move_destinationStageId_fkey";

-- DropForeignKey
ALTER TABLE "action_move" DROP CONSTRAINT "action_move_pubId_fkey";

-- DropForeignKey
ALTER TABLE "action_move" DROP CONSTRAINT "action_move_sourceStageId_fkey";

-- DropForeignKey
ALTER TABLE "action_move" DROP CONSTRAINT "action_move_userId_fkey";

-- DropForeignKey
ALTER TABLE "form_elements" DROP CONSTRAINT "form_elements_fieldId_fkey";

-- DropForeignKey
ALTER TABLE "form_elements" DROP CONSTRAINT "form_elements_formId_fkey";

-- DropForeignKey
ALTER TABLE "forms" DROP CONSTRAINT "forms_communityId_fkey";

-- DropForeignKey
ALTER TABLE "member_groups" DROP CONSTRAINT "member_groups_communityId_fkey";

-- DropForeignKey
ALTER TABLE "members" DROP CONSTRAINT "members_userId_fkey";

-- DropForeignKey
ALTER TABLE "permissions" DROP CONSTRAINT "permissions_memberGroupId_fkey";

-- DropForeignKey
ALTER TABLE "permissions" DROP CONSTRAINT "permissions_memberId_fkey";

-- DropTable
DROP TABLE "action_claim";

-- DropTable
DROP TABLE "action_move";

-- AddForeignKey
ALTER TABLE "members" ADD CONSTRAINT "members_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "member_groups" ADD CONSTRAINT "member_groups_communityId_fkey" FOREIGN KEY ("communityId") REFERENCES "communities"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "permissions" ADD CONSTRAINT "permissions_memberId_fkey" FOREIGN KEY ("memberId") REFERENCES "members"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "permissions" ADD CONSTRAINT "permissions_memberGroupId_fkey" FOREIGN KEY ("memberGroupId") REFERENCES "member_groups"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "forms" ADD CONSTRAINT "forms_communityId_fkey" FOREIGN KEY ("communityId") REFERENCES "communities"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "form_elements" ADD CONSTRAINT "form_elements_fieldId_fkey" FOREIGN KEY ("fieldId") REFERENCES "pub_fields"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "form_elements" ADD CONSTRAINT "form_elements_formId_fkey" FOREIGN KEY ("formId") REFERENCES "forms"("id") ON DELETE CASCADE ON UPDATE CASCADE;
174 changes: 174 additions & 0 deletions core/prisma/migrations/20241007162428_update_comments/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
-- generator-version: 1.0.0

-- Model users comments



-- Model sessions comments

COMMENT ON COLUMN "sessions"."type" IS 'With what type of token is this session created? Used for determining on a page-by-page basis whether to allow a certain session to access it. For instance, a verify email token/session should not allow you to access the password reset page.';


-- Model auth_tokens comments



-- Model communities comments



-- Model pubs comments



-- Model pub_fields comments



-- Model PubFieldSchema comments

COMMENT ON COLUMN "PubFieldSchema"."schema" IS '@type(JSONSchemaType<any>, ''ajv'', true, false, true)';


-- Model pub_values comments



-- Model pub_types comments



-- Model stages comments



-- Model PubsInStages comments



-- Model move_constraint comments



-- Model members comments



-- Model member_groups comments



-- Model permissions comments



-- Model integrations comments



-- Model integration_instances comments



-- Model IntegrationInstanceState comments



-- Model action_instances comments



-- Model action_runs comments



-- Model rules comments



-- Model forms comments



-- Model form_elements comments



-- Model api_access_tokens comments



-- Model api_access_logs comments



-- Model api_access_permissions comments

COMMENT ON COLUMN "api_access_permissions"."constraints" IS '@type(ApiAccessPermissionConstraints, ''../types'', true, false, true)';


-- Model form_to_permissions comments



-- Enum AuthTokenType comments

COMMENT ON TYPE "AuthTokenType" IS '@property generic - For most use-cases. This will just authenticate you with a regular session.
@property passwordReset - For resetting your password only
@property signup - For signing up, but also when you''re invited to a community
@property verifyEmail - For verifying your email address';


-- Enum CoreSchemaType comments




-- Enum MemberRole comments




-- Enum Action comments




-- Enum ActionRunStatus comments




-- Enum Event comments




-- Enum FormAccessType comments




-- Enum StructuralFormElement comments




-- Enum ElementType comments




-- Enum InputComponent comments




-- Enum ApiAccessType comments




-- Enum ApiAccessScope comments


Loading

0 comments on commit 5d75b1f

Please sign in to comment.