-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from sinamics/dev
Merge dev branch
- Loading branch information
Showing
35 changed files
with
881 additions
and
395 deletions.
There are no files selected for viewing
This file contains 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,6 +1,7 @@ | ||
{ | ||
"recommendations": [ | ||
"prisma.prisma", | ||
"rome.rome" | ||
"rome.rome", | ||
"bradlc.vscode-tailwindcss" | ||
] | ||
} |
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
34 changes: 34 additions & 0 deletions
34
prisma/migrations/20230811063619_user_options/migration.sql
This file contains 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,34 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the column `showNotationMarkerInTableRow` on the `GlobalOptions` table. All the data in the column will be lost. | ||
- You are about to drop the column `useNotationColorAsBg` on the `GlobalOptions` table. All the data in the column will be lost. | ||
- You are about to drop the column `ztCentralApiKey` on the `GlobalOptions` table. All the data in the column will be lost. | ||
- You are about to drop the column `ztCentralApiUrl` on the `GlobalOptions` table. All the data in the column will be lost. | ||
*/ | ||
-- AlterTable | ||
ALTER TABLE "GlobalOptions" DROP COLUMN "showNotationMarkerInTableRow", | ||
DROP COLUMN "useNotationColorAsBg", | ||
DROP COLUMN "ztCentralApiKey", | ||
DROP COLUMN "ztCentralApiUrl"; | ||
|
||
-- CreateTable | ||
CREATE TABLE "UserOptions" ( | ||
"id" SERIAL NOT NULL, | ||
"userId" INTEGER NOT NULL, | ||
"useNotationColorAsBg" BOOLEAN DEFAULT false, | ||
"showNotationMarkerInTableRow" BOOLEAN DEFAULT true, | ||
"ztCentralApiKey" TEXT DEFAULT '', | ||
"ztCentralApiUrl" TEXT DEFAULT 'https://api.zerotier.com/api/v1', | ||
"localControllerUrl" TEXT DEFAULT 'http://zerotier:9993', | ||
"localControllerSecret" TEXT DEFAULT '', | ||
|
||
CONSTRAINT "UserOptions_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "UserOptions_userId_key" ON "UserOptions"("userId"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "UserOptions" ADD CONSTRAINT "UserOptions_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
This file contains 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 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,19 @@ | ||
import { seedUserOptions } from "./seeds/user-option.seed"; | ||
import { PrismaClient } from "@prisma/client"; | ||
|
||
const prisma = new PrismaClient(); | ||
|
||
async function main() { | ||
await seedUserOptions(); | ||
// rome-ignore lint/nursery/noConsoleLog: <explanation> | ||
console.log("Seeding User Options complete!"); | ||
} | ||
|
||
main() | ||
.catch((e) => { | ||
console.error(e); | ||
process.exit(1); | ||
}) | ||
.finally(async () => { | ||
await prisma.$disconnect(); | ||
}); |
This file contains 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,32 @@ | ||
import { PrismaClient } from "@prisma/client"; | ||
|
||
const prisma = new PrismaClient(); | ||
|
||
export async function seedUserOptions() { | ||
// Fetch all users from the database | ||
const users = await prisma.user.findMany(); | ||
|
||
for (const user of users) { | ||
// Check if UserOptions exist for each user | ||
const userOptionExists = await prisma.userOptions.findUnique({ | ||
where: { userId: user.id }, | ||
}); | ||
// If UserOptions do not exist for a user, create them | ||
if (!userOptionExists) { | ||
await prisma.userOptions.create({ | ||
data: { | ||
userId: user.id, | ||
useNotationColorAsBg: false, | ||
showNotationMarkerInTableRow: true, | ||
ztCentralApiKey: "", | ||
ztCentralApiUrl: "https://api.zerotier.com/api/v1", | ||
localControllerUrl: "http://zerotier:9993", | ||
localControllerSecret: "", | ||
}, | ||
}); | ||
} | ||
} | ||
|
||
// rome-ignore lint/nursery/noConsoleLog: <explanation> | ||
console.log("Seeding User Options complete!"); | ||
} |
This file contains 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 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 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 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
Oops, something went wrong.