Skip to content

Commit 15b1e83

Browse files
Merge branch 'main' into environment/staging
2 parents 8fabe6f + 298de75 commit 15b1e83

File tree

96 files changed

+2193
-581
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+2193
-581
lines changed

packages/core/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
.env.staging
33
.env.production
44

5+
prisma/schema.prisma
6+
57
**/secrets/*
68

packages/core/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"dev": "yarn compile:watch",
88
"compile": "tsc -p tsconfig.json && yarn fix:paths",
99
"compile:watch": "tsc-watch --onSuccess \"yarn fix:paths\"",
10-
"fix:paths": "tscpaths -p tsconfig.json -s ./src -o ./dist"
10+
"fix:paths": "tscpaths -p tsconfig.json -s ./src -o ./dist",
11+
"create:schema": "find prisma -name '*.prisma' -not -name \"schema.prisma\" -exec cat {} + > prisma/schema.prisma && prisma format",
12+
"create:migration": "yarn create:schema && prisma migrate dev"
1113
},
1214
"devDependencies": {
1315
"@types/request-ip": "^0.0.35",

packages/core/prisma/base.prisma

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
datasource db {
2+
provider = "postgresql"
3+
url = env("Database.Url")
4+
}
5+
6+
generator client {
7+
provider = "prisma-client-js"
8+
}
9+
10+
// ---- Shared
11+
12+
enum FundingType {
13+
OneTime
14+
Monthly
15+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
-- CreateEnum
2+
CREATE TYPE "DiscussionType" AS ENUM ('ProposalDiscussion', 'CommonDiscussion');
3+
4+
-- CreateEnum
5+
CREATE TYPE "DiscussionSubscriptionType" AS ENUM ('AllNotifications', 'OnlyMentions', 'NoNotification');
6+
7+
-- CreateEnum
8+
CREATE TYPE "DiscussionMessageType" AS ENUM ('Message');
9+
10+
-- CreateTable
11+
CREATE TABLE "Discussion"
12+
(
13+
"id" TEXT NOT NULL,
14+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
15+
"updatedAt" TIMESTAMP(3) NOT NULL,
16+
"topic" TEXT NOT NULL,
17+
"description" TEXT NOT NULL,
18+
"latestMessage" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
19+
20+
PRIMARY KEY ("id")
21+
);
22+
23+
-- CreateTable
24+
CREATE TABLE "DiscussionSubscription"
25+
(
26+
"id" TEXT NOT NULL,
27+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
28+
"updatedAt" TIMESTAMP(3) NOT NULL,
29+
"latestMessageSeen" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
30+
"type" "DiscussionSubscriptionType" NOT NULL DEFAULT E'AllNotifications',
31+
"discussionId" TEXT NOT NULL,
32+
33+
PRIMARY KEY ("id")
34+
);
35+
36+
-- CreateTable
37+
CREATE TABLE "DiscussionMessage"
38+
(
39+
"id" TEXT NOT NULL,
40+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
41+
"updatedAt" TIMESTAMP(3) NOT NULL,
42+
"type" "DiscussionMessageType" NOT NULL DEFAULT E'Message',
43+
"message" TEXT NOT NULL,
44+
"discussionId" TEXT,
45+
46+
PRIMARY KEY ("id")
47+
);
48+
49+
-- AddForeignKey
50+
ALTER TABLE "DiscussionSubscription"
51+
ADD FOREIGN KEY ("discussionId") REFERENCES "Discussion" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
52+
53+
-- AddForeignKey
54+
ALTER TABLE "DiscussionMessage"
55+
ADD FOREIGN KEY ("discussionId") REFERENCES "Discussion" ("id") ON DELETE SET NULL ON UPDATE CASCADE;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
Warnings:
3+
4+
- You are about to drop the column `latestMessageSeen` on the `DiscussionSubscription` table. All the data in the column will be lost.
5+
- Added the required column `userId` to the `DiscussionMessage` table without a default value. This is not possible if the table is not empty.
6+
- Made the column `discussionId` on table `DiscussionMessage` required. This step will fail if there are existing NULL values in that column.
7+
- Added the required column `userId` to the `DiscussionSubscription` table without a default value. This is not possible if the table is not empty.
8+
9+
*/
10+
-- AlterTable
11+
ALTER TABLE "DiscussionMessage"
12+
ADD COLUMN "userId" TEXT NOT NULL,
13+
ALTER COLUMN "discussionId" SET NOT NULL;
14+
15+
-- AlterTable
16+
ALTER TABLE "DiscussionSubscription"
17+
DROP COLUMN "latestMessageSeen",
18+
ADD COLUMN "userId" TEXT NOT NULL;
19+
20+
-- AddForeignKey
21+
ALTER TABLE "DiscussionMessage"
22+
ADD FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
23+
24+
-- AddForeignKey
25+
ALTER TABLE "DiscussionSubscription"
26+
ADD FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
Warnings:
3+
4+
- Added the required column `commonId` to the `Discussion` table without a default value. This is not possible if the table is not empty.
5+
6+
*/
7+
-- AlterTable
8+
ALTER TABLE "Discussion"
9+
ADD COLUMN "commonId" TEXT NOT NULL,
10+
ADD COLUMN "proposalId" TEXT;
11+
12+
-- AddForeignKey
13+
ALTER TABLE "Discussion"
14+
ADD FOREIGN KEY ("commonId") REFERENCES "Common" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
15+
16+
-- AddForeignKey
17+
ALTER TABLE "Discussion"
18+
ADD FOREIGN KEY ("proposalId") REFERENCES "Proposal" ("id") ON DELETE SET NULL ON UPDATE CASCADE;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
Warnings:
3+
4+
- Added the required column `userId` to the `Discussion` table without a default value. This is not possible if the table is not empty.
5+
6+
*/
7+
-- AlterTable
8+
ALTER TABLE "Discussion"
9+
ADD COLUMN "userId" TEXT NOT NULL;
10+
11+
-- AddForeignKey
12+
ALTER TABLE "Discussion"
13+
ADD FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- AlterEnum
2+
-- This migration adds more than one value to an enum.
3+
-- With PostgreSQL versions 11 and earlier, this is not possible
4+
-- in a single migration. This can be worked around by creating
5+
-- multiple migrations, each migration adding only one value to
6+
-- the enum.
7+
8+
9+
ALTER TYPE "EventType" ADD VALUE 'DiscussionCreated';
10+
ALTER TYPE "EventType" ADD VALUE 'DiscussionMessageCreated';
11+
ALTER TYPE "EventType" ADD VALUE 'DiscussionSubscriptionCreated';
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
Warnings:
3+
4+
- Added the required column `type` to the `Discussion` table without a default value. This is not possible if the table is not empty.
5+
6+
*/
7+
-- AlterTable
8+
ALTER TABLE "Discussion" ADD COLUMN "type" "DiscussionType" NOT NULL;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- AlterEnum
2+
ALTER TYPE "EventType" ADD VALUE 'DiscussionSubscriptionTypeChanged';

0 commit comments

Comments
 (0)