-
Notifications
You must be signed in to change notification settings - Fork 10
techref: Pub tables and Workflows #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0b4c516
techref: Pub tables and Workflows
gabestein 649bfee
update: Adjust schema approach to metadata fields and values
isTravis a5e3226
dev: Update prisma schema to have first pass at workflows and stages …
isTravis 9b5bd59
dev: Fix User relation names
isTravis d828cc4
dev: Fix Pub relation names
isTravis f752085
Update TECH_REF.MD
gabestein 34b929a
Update TECH_REF.MD
gabestein File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,7 +1,25 @@ | ||
| export default function Page() { | ||
| import prisma from "prisma/db"; | ||
|
|
||
| export default async function Page() { | ||
| /* Normally, we would get the community based on the url or logged in user session */ | ||
| const onlyCommunity = await prisma.community.findFirst(); | ||
| if (!onlyCommunity) { | ||
| return null; | ||
| } | ||
| const workflows = await prisma.workflow.findMany({ | ||
| where: { communityId: onlyCommunity.id }, | ||
| include: { | ||
| stages: { | ||
| include: { | ||
| moveConstraints: true, | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
| return ( | ||
| <> | ||
| <h1>Workflows</h1> | ||
| <pre>{JSON.stringify(workflows, null, 4)}</pre> | ||
| </> | ||
| ); | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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
51 changes: 51 additions & 0 deletions
51
prisma/migrations/20230622182329_metadata_refactor/migration.sql
This file contains hidden or 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,51 @@ | ||
| /* | ||
| Warnings: | ||
|
|
||
| - You are about to drop the column `fields` on the `pub_types` table. All the data in the column will be lost. | ||
| - You are about to drop the `metadata` table. If the table is not empty, all the data it contains will be lost. | ||
| - Added the required column `metadataBlob` to the `pubs` table without a default value. This is not possible if the table is not empty. | ||
|
|
||
| */ | ||
| -- DropForeignKey | ||
| ALTER TABLE "metadata" DROP CONSTRAINT "metadata_pub_id_fkey"; | ||
|
|
||
| -- AlterTable | ||
| ALTER TABLE "pub_types" DROP COLUMN "fields"; | ||
|
|
||
| -- AlterTable | ||
| ALTER TABLE "pubs" ADD COLUMN "metadataBlob" JSONB NOT NULL; | ||
|
|
||
| -- DropTable | ||
| DROP TABLE "metadata"; | ||
|
|
||
| -- CreateTable | ||
| CREATE TABLE "metadata_fields" ( | ||
| "id" TEXT NOT NULL, | ||
| "name" TEXT NOT NULL, | ||
| "pub_type_id" TEXT NOT NULL, | ||
| "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| "updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
|
|
||
| CONSTRAINT "metadata_fields_pkey" PRIMARY KEY ("id") | ||
| ); | ||
|
|
||
| -- CreateTable | ||
| CREATE TABLE "metadata_values" ( | ||
| "id" TEXT NOT NULL, | ||
| "field_id" TEXT NOT NULL, | ||
| "value" JSONB NOT NULL, | ||
| "pub_id" TEXT NOT NULL, | ||
| "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| "updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
|
|
||
| CONSTRAINT "metadata_values_pkey" PRIMARY KEY ("id") | ||
| ); | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "metadata_fields" ADD CONSTRAINT "metadata_fields_pub_type_id_fkey" FOREIGN KEY ("pub_type_id") REFERENCES "pub_types"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "metadata_values" ADD CONSTRAINT "metadata_values_field_id_fkey" FOREIGN KEY ("field_id") REFERENCES "metadata_fields"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "metadata_values" ADD CONSTRAINT "metadata_values_pub_id_fkey" FOREIGN KEY ("pub_id") REFERENCES "pubs"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
This file contains hidden or 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,2 @@ | ||
| -- AlterTable | ||
| ALTER TABLE "pubs" ALTER COLUMN "metadataBlob" DROP NOT NULL; |
94 changes: 94 additions & 0 deletions
94
prisma/migrations/20230622194921_workflow_init/migration.sql
This file contains hidden or 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,94 @@ | ||
| /* | ||
| Warnings: | ||
|
|
||
| - Added the required column `workflow_id` to the `stages` table without a default value. This is not possible if the table is not empty. | ||
|
|
||
| */ | ||
| -- AlterTable | ||
| ALTER TABLE "stages" ADD COLUMN "workflow_id" TEXT NOT NULL; | ||
|
|
||
| -- CreateTable | ||
| CREATE TABLE "move_constraint" ( | ||
| "id" TEXT NOT NULL, | ||
| "stage_id" TEXT NOT NULL, | ||
| "destination_id" TEXT NOT NULL, | ||
| "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| "updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
|
|
||
| CONSTRAINT "move_constraint_pkey" PRIMARY KEY ("id") | ||
| ); | ||
|
|
||
| -- CreateTable | ||
| CREATE TABLE "action_claim" ( | ||
| "id" TEXT NOT NULL, | ||
| "stage_id" TEXT NOT NULL, | ||
| "pub_id" TEXT NOT NULL, | ||
| "user_id" TEXT NOT NULL, | ||
| "releasedAt" TIMESTAMP(3), | ||
| "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| "updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
|
|
||
| CONSTRAINT "action_claim_pkey" PRIMARY KEY ("id") | ||
| ); | ||
|
|
||
| -- CreateTable | ||
| CREATE TABLE "action_move" ( | ||
| "id" TEXT NOT NULL, | ||
| "source_stage_id" TEXT NOT NULL, | ||
| "destination_stage_id" TEXT NOT NULL, | ||
| "pub_id" TEXT NOT NULL, | ||
| "user_id" TEXT NOT NULL, | ||
| "note" TEXT NOT NULL, | ||
| "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| "updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
|
|
||
| CONSTRAINT "action_move_pkey" PRIMARY KEY ("id") | ||
| ); | ||
|
|
||
| -- CreateTable | ||
| CREATE TABLE "_PubToStage" ( | ||
| "A" TEXT NOT NULL, | ||
| "B" TEXT NOT NULL | ||
| ); | ||
|
|
||
| -- CreateIndex | ||
| CREATE UNIQUE INDEX "_PubToStage_AB_unique" ON "_PubToStage"("A", "B"); | ||
|
|
||
| -- CreateIndex | ||
| CREATE INDEX "_PubToStage_B_index" ON "_PubToStage"("B"); | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "stages" ADD CONSTRAINT "stages_workflow_id_fkey" FOREIGN KEY ("workflow_id") REFERENCES "workflows"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "move_constraint" ADD CONSTRAINT "move_constraint_stage_id_fkey" FOREIGN KEY ("stage_id") REFERENCES "stages"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "move_constraint" ADD CONSTRAINT "move_constraint_destination_id_fkey" FOREIGN KEY ("destination_id") REFERENCES "stages"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "action_claim" ADD CONSTRAINT "action_claim_stage_id_fkey" FOREIGN KEY ("stage_id") REFERENCES "stages"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "action_claim" ADD CONSTRAINT "action_claim_pub_id_fkey" FOREIGN KEY ("pub_id") REFERENCES "pubs"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "action_claim" ADD CONSTRAINT "action_claim_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "action_move" ADD CONSTRAINT "action_move_source_stage_id_fkey" FOREIGN KEY ("source_stage_id") REFERENCES "stages"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "action_move" ADD CONSTRAINT "action_move_destination_stage_id_fkey" FOREIGN KEY ("destination_stage_id") REFERENCES "stages"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "action_move" ADD CONSTRAINT "action_move_pub_id_fkey" FOREIGN KEY ("pub_id") REFERENCES "pubs"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "action_move" ADD CONSTRAINT "action_move_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "_PubToStage" ADD CONSTRAINT "_PubToStage_A_fkey" FOREIGN KEY ("A") REFERENCES "pubs"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "_PubToStage" ADD CONSTRAINT "_PubToStage_B_fkey" FOREIGN KEY ("B") REFERENCES "stages"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
11 changes: 11 additions & 0 deletions
11
prisma/migrations/20230622195031_workflows_to_community/migration.sql
This file contains hidden or 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,11 @@ | ||
| /* | ||
| Warnings: | ||
|
|
||
| - Added the required column `community_id` to the `workflows` table without a default value. This is not possible if the table is not empty. | ||
|
|
||
| */ | ||
| -- AlterTable | ||
| ALTER TABLE "workflows" ADD COLUMN "community_id" TEXT NOT NULL; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE "workflows" ADD CONSTRAINT "workflows_community_id_fkey" FOREIGN KEY ("community_id") REFERENCES "communities"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
14 changes: 14 additions & 0 deletions
14
prisma/migrations/20230622195558_stage_names_order/migration.sql
This file contains hidden or 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,14 @@ | ||
| /* | ||
| Warnings: | ||
|
|
||
| - Added the required column `name` to the `stages` table without a default value. This is not possible if the table is not empty. | ||
| - Added the required column `order` to the `stages` table without a default value. This is not possible if the table is not empty. | ||
| - Added the required column `name` to the `workflows` table without a default value. This is not possible if the table is not empty. | ||
|
|
||
| */ | ||
| -- AlterTable | ||
| ALTER TABLE "stages" ADD COLUMN "name" TEXT NOT NULL, | ||
| ADD COLUMN "order" TEXT NOT NULL; | ||
|
|
||
| -- AlterTable | ||
| ALTER TABLE "workflows" ADD COLUMN "name" TEXT NOT NULL; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't my understanding. My understanding was that integrations can cause either internal or external side-effects (perhaps both), and that those were defined as:
The former is internal to our platform (e.g. edits the title, generates a new file, creates a review). The latter is external to our platform (e.g. builds a website, posts to slack, deposits to archival service).