Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Add user wait list schema
Browse files Browse the repository at this point in the history
  • Loading branch information
anduong96 committed Nov 29, 2023
1 parent a5496ab commit ac9c93a
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
15 changes: 15 additions & 0 deletions prisma/migrations/20231129235604_/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- CreateTable
CREATE TABLE "UserWaitList" (
"id" TEXT NOT NULL,
"userID" TEXT NOT NULL,
"feature" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT "UserWaitList_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "UserWaitList_userID_feature_key" ON "UserWaitList"("userID", "feature");

-- AddForeignKey
ALTER TABLE "UserWaitList" ADD CONSTRAINT "UserWaitList_userID_fkey" FOREIGN KEY ("userID") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
13 changes: 13 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ model User {
Authentications UserAuthentication[]
UserFlight UserFlight[]
UserPreference UserPreference?
UserWaitList UserWaitList[]
}

model UserAuthentication {
Expand Down Expand Up @@ -458,6 +459,18 @@ model UserFlight {
@@unique([flightID, userID])
}

model UserWaitList {
id String @id @default(uuid())
userID String
feature String
createdAt DateTime @default(now())
// @skip
User User @relation(fields: [userID], references: [id])
@@unique([userID, feature])
}

model UserPreference {
id String @id @default(uuid())
userID String
Expand Down
8 changes: 8 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ input UpdateUserPreferenceInput {
type User {
UserFlight: [UserFlight!]!
UserPreference: UserPreference
UserWaitList: [UserWaitList!]!
avatarURL: String
createdAt: DateTimeISO!
displayName: String
Expand All @@ -284,4 +285,11 @@ type UserPreference {
id: ID!
measurement: MeasurementType!
userID: String!
}

type UserWaitList {
createdAt: DateTimeISO!
feature: String!
id: ID!
userID: String!
}
4 changes: 4 additions & 0 deletions src/@generated/graphql/models/User.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Field, ObjectType, ID } from 'type-graphql';
import { GQL_UserFlight } from './UserFlight';
import { GQL_UserPreference } from './UserPreference';
import { GQL_UserWaitList } from './UserWaitList';

@ObjectType('User')
export class GQL_User {
Expand Down Expand Up @@ -31,5 +32,8 @@ export class GQL_User {
@Field(() => GQL_UserPreference, { nullable: true })
UserPreference?: GQL_UserPreference;

@Field(() => [GQL_UserWaitList])
UserWaitList: GQL_UserWaitList[];

// skip overwrite 👇
}
18 changes: 18 additions & 0 deletions src/@generated/graphql/models/UserWaitList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Field, ObjectType, ID } from 'type-graphql';

@ObjectType('UserWaitList')
export class GQL_UserWaitList {
@Field(() => ID)
id: string;

@Field()
userID: string;

@Field()
feature: string;

@Field()
createdAt: Date;

// skip overwrite 👇
}

0 comments on commit ac9c93a

Please sign in to comment.