Skip to content

Commit 6d17f54

Browse files
committed
feat(qrCode): add QrCode model with relations and migration
- Introduce QrCode model in Prisma schema with fields: id, code, dashboardId, timestamps - Add foreign key relation from QrCode to Dashboard with indexes and unique constraints - Create SQL migration to add QrCode table and associated indexes and constraints - Update Prisma client generation to include QrCode CRUD operations and types - Add relation fields for qrCodes on Dashboard model and related input types - Add es-toolkit dependency to package.json and package-lock.json for toolkit support
1 parent d7b7a92 commit 6d17f54

File tree

27 files changed

+3777
-77
lines changed

27 files changed

+3777
-77
lines changed

web/package-lock.json

Lines changed: 13 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"@tailwindcss/vite": "^4.1.4",
5050
"@trpc/client": "^10.45.2",
5151
"@trpc/server": "^10.45.2",
52+
"es-toolkit": "^1.41.0",
5253
"isomorphic-fetch": "^3.0.0",
5354
"postcss": "^8.5.3",
5455
"qrcode": "^1.5.4",
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-- CreateTable
2+
CREATE TABLE "QrCode" (
3+
"id" UUID NOT NULL,
4+
"code" TEXT NOT NULL,
5+
"dashboardId" UUID NOT NULL,
6+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
7+
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
8+
"deletedAt" TIMESTAMP(3),
9+
10+
CONSTRAINT "PK_QRCODE" PRIMARY KEY ("id")
11+
);
12+
13+
-- CreateIndex
14+
CREATE INDEX "IDX_QRCODE__DASHBOARD_ID" ON "QrCode"("dashboardId");
15+
16+
-- CreateIndex
17+
CREATE UNIQUE INDEX "UQ_QRCODE__CODE" ON "QrCode"("dashboardId", "code");
18+
19+
-- AddForeignKey
20+
ALTER TABLE "QrCode" ADD CONSTRAINT "FK_QRCODE__DASHBOARD_ID" FOREIGN KEY ("dashboardId") REFERENCES "Dashboard"("id") ON DELETE NO ACTION ON UPDATE NO ACTION;

web/prisma/schema.prisma

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,28 @@ model Dashboard {
5656
createdAt DateTime @default(now())
5757
updatedAt DateTime @default(now())
5858
deletedAt DateTime?
59+
qrCodes QrCode[] @relation(map: "FK_WIDGET__DASHBOARD_ID")
5960
6061
@@unique([userId, name], map: "UQ_DASHBOARD__USER_ID_NAME")
6162
@@unique([deviceId], map: "UQ_DASHBOARD__DEVICE_ID")
6263
@@index([userId], map: "IDX_DASHBOARD__USER_ID")
6364
}
6465

66+
model QrCode {
67+
id String @id(map: "PK_QRCODE") @default(uuid()) @db.Uuid
68+
code String
69+
70+
dashboardId String @db.Uuid
71+
Dashboard Dashboard @relation(fields: [dashboardId], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "FK_QRCODE__DASHBOARD_ID")
72+
73+
createdAt DateTime @default(now())
74+
updatedAt DateTime @default(now())
75+
deletedAt DateTime?
76+
77+
@@unique([dashboardId, code], map: "UQ_QRCODE__CODE")
78+
@@index([dashboardId], map: "IDX_QRCODE__DASHBOARD_ID")
79+
}
80+
6581
model Widget {
6682
id String @id(map: "PK_WIDGET") @default(uuid()) @db.Uuid
6783
options Json?

web/src/app/generated/prisma/browser.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ export type Session = Prisma.SessionModel
3232
*
3333
*/
3434
export type Dashboard = Prisma.DashboardModel
35+
/**
36+
* Model QrCode
37+
*
38+
*/
39+
export type QrCode = Prisma.QrCodeModel
3540
/**
3641
* Model Widget
3742
*

web/src/app/generated/prisma/client.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ export type Session = Prisma.SessionModel
5656
*
5757
*/
5858
export type Dashboard = Prisma.DashboardModel
59+
/**
60+
* Model QrCode
61+
*
62+
*/
63+
export type QrCode = Prisma.QrCodeModel
5964
/**
6065
* Model Widget
6166
*

web/src/app/generated/prisma/internal/class.ts

Lines changed: 13 additions & 3 deletions
Large diffs are not rendered by default.

web/src/app/generated/prisma/internal/prismaNamespace.ts

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ export const ModelName = {
393393
User: 'User',
394394
Session: 'Session',
395395
Dashboard: 'Dashboard',
396+
QrCode: 'QrCode',
396397
Widget: 'Widget',
397398
WidgetLog: 'WidgetLog'
398399
} as const
@@ -410,7 +411,7 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
410411
omit: GlobalOmitOptions
411412
}
412413
meta: {
413-
modelProps: "user" | "session" | "dashboard" | "widget" | "widgetLog"
414+
modelProps: "user" | "session" | "dashboard" | "qrCode" | "widget" | "widgetLog"
414415
txIsolationLevel: TransactionIsolationLevel
415416
}
416417
model: {
@@ -636,6 +637,80 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
636637
}
637638
}
638639
}
640+
QrCode: {
641+
payload: Prisma.$QrCodePayload<ExtArgs>
642+
fields: Prisma.QrCodeFieldRefs
643+
operations: {
644+
findUnique: {
645+
args: Prisma.QrCodeFindUniqueArgs<ExtArgs>
646+
result: runtime.Types.Utils.PayloadToResult<Prisma.$QrCodePayload> | null
647+
}
648+
findUniqueOrThrow: {
649+
args: Prisma.QrCodeFindUniqueOrThrowArgs<ExtArgs>
650+
result: runtime.Types.Utils.PayloadToResult<Prisma.$QrCodePayload>
651+
}
652+
findFirst: {
653+
args: Prisma.QrCodeFindFirstArgs<ExtArgs>
654+
result: runtime.Types.Utils.PayloadToResult<Prisma.$QrCodePayload> | null
655+
}
656+
findFirstOrThrow: {
657+
args: Prisma.QrCodeFindFirstOrThrowArgs<ExtArgs>
658+
result: runtime.Types.Utils.PayloadToResult<Prisma.$QrCodePayload>
659+
}
660+
findMany: {
661+
args: Prisma.QrCodeFindManyArgs<ExtArgs>
662+
result: runtime.Types.Utils.PayloadToResult<Prisma.$QrCodePayload>[]
663+
}
664+
create: {
665+
args: Prisma.QrCodeCreateArgs<ExtArgs>
666+
result: runtime.Types.Utils.PayloadToResult<Prisma.$QrCodePayload>
667+
}
668+
createMany: {
669+
args: Prisma.QrCodeCreateManyArgs<ExtArgs>
670+
result: BatchPayload
671+
}
672+
createManyAndReturn: {
673+
args: Prisma.QrCodeCreateManyAndReturnArgs<ExtArgs>
674+
result: runtime.Types.Utils.PayloadToResult<Prisma.$QrCodePayload>[]
675+
}
676+
delete: {
677+
args: Prisma.QrCodeDeleteArgs<ExtArgs>
678+
result: runtime.Types.Utils.PayloadToResult<Prisma.$QrCodePayload>
679+
}
680+
update: {
681+
args: Prisma.QrCodeUpdateArgs<ExtArgs>
682+
result: runtime.Types.Utils.PayloadToResult<Prisma.$QrCodePayload>
683+
}
684+
deleteMany: {
685+
args: Prisma.QrCodeDeleteManyArgs<ExtArgs>
686+
result: BatchPayload
687+
}
688+
updateMany: {
689+
args: Prisma.QrCodeUpdateManyArgs<ExtArgs>
690+
result: BatchPayload
691+
}
692+
updateManyAndReturn: {
693+
args: Prisma.QrCodeUpdateManyAndReturnArgs<ExtArgs>
694+
result: runtime.Types.Utils.PayloadToResult<Prisma.$QrCodePayload>[]
695+
}
696+
upsert: {
697+
args: Prisma.QrCodeUpsertArgs<ExtArgs>
698+
result: runtime.Types.Utils.PayloadToResult<Prisma.$QrCodePayload>
699+
}
700+
aggregate: {
701+
args: Prisma.QrCodeAggregateArgs<ExtArgs>
702+
result: runtime.Types.Utils.Optional<Prisma.AggregateQrCode>
703+
}
704+
groupBy: {
705+
args: Prisma.QrCodeGroupByArgs<ExtArgs>
706+
result: runtime.Types.Utils.Optional<Prisma.QrCodeGroupByOutputType>[]
707+
}
708+
count: {
709+
args: Prisma.QrCodeCountArgs<ExtArgs>
710+
result: runtime.Types.Utils.Optional<Prisma.QrCodeCountAggregateOutputType> | number
711+
}
712+
}
713+
}
639714
Widget: {
640715
payload: Prisma.$WidgetPayload<ExtArgs>
641716
fields: Prisma.WidgetFieldRefs
@@ -860,6 +935,18 @@ export const DashboardScalarFieldEnum = {
860935
export type DashboardScalarFieldEnum = (typeof DashboardScalarFieldEnum)[keyof typeof DashboardScalarFieldEnum]
861936

862937

938+
export const QrCodeScalarFieldEnum = {
939+
id: 'id',
940+
code: 'code',
941+
dashboardId: 'dashboardId',
942+
createdAt: 'createdAt',
943+
updatedAt: 'updatedAt',
944+
deletedAt: 'deletedAt'
945+
} as const
946+
947+
export type QrCodeScalarFieldEnum = (typeof QrCodeScalarFieldEnum)[keyof typeof QrCodeScalarFieldEnum]
948+
949+
863950
export const WidgetScalarFieldEnum = {
864951
id: 'id',
865952
options: 'options',
@@ -1110,6 +1197,7 @@ export type GlobalOmitConfig = {
11101197
user?: Prisma.UserOmit
11111198
session?: Prisma.SessionOmit
11121199
dashboard?: Prisma.DashboardOmit
1200+
qrCode?: Prisma.QrCodeOmit
11131201
widget?: Prisma.WidgetOmit
11141202
widgetLog?: Prisma.WidgetLogOmit
11151203
}

web/src/app/generated/prisma/internal/prismaNamespaceBrowser.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export const ModelName = {
5252
User: 'User',
5353
Session: 'Session',
5454
Dashboard: 'Dashboard',
55+
QrCode: 'QrCode',
5556
Widget: 'Widget',
5657
WidgetLog: 'WidgetLog'
5758
} as const
@@ -109,6 +110,18 @@ export const DashboardScalarFieldEnum = {
109110
export type DashboardScalarFieldEnum = (typeof DashboardScalarFieldEnum)[keyof typeof DashboardScalarFieldEnum]
110111

111112

113+
export const QrCodeScalarFieldEnum = {
114+
id: 'id',
115+
code: 'code',
116+
dashboardId: 'dashboardId',
117+
createdAt: 'createdAt',
118+
updatedAt: 'updatedAt',
119+
deletedAt: 'deletedAt'
120+
} as const
121+
122+
export type QrCodeScalarFieldEnum = (typeof QrCodeScalarFieldEnum)[keyof typeof QrCodeScalarFieldEnum]
123+
124+
112125
export const WidgetScalarFieldEnum = {
113126
id: 'id',
114127
options: 'options',

web/src/app/generated/prisma/models.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
export type * from './models/User'
1212
export type * from './models/Session'
1313
export type * from './models/Dashboard'
14+
export type * from './models/QrCode'
1415
export type * from './models/Widget'
1516
export type * from './models/WidgetLog'
1617
export type * from './commonInputTypes'

0 commit comments

Comments
 (0)