From 490150f9b76148a65e59e0a5e8535e5a2b6342e8 Mon Sep 17 00:00:00 2001 From: i701 Date: Sat, 30 Nov 2024 23:38:20 +0500 Subject: [PATCH] Refactor user actions and authentication components - Updated user verification logic to include atoll and island relationships. - Introduced CreateClient function for integrating with external client API. - Replaced 'house_name' with 'address' in user signup data handling. - Added new Checkbox component for improved UI interactions. - Migrated database provider from SQLite to PostgreSQL and redefined user schema. - Removed obsolete migration files and ensured database integrity with new structure. --- actions/auth-actions.ts | 4 +- actions/ninja/client.ts | 89 ++++++++++++++ actions/user-actions.ts | 25 +++- components/ui/checkbox.tsx | 30 +++++ .../20241124133417_add/migration.sql | 63 ---------- .../20241124133512_add/migration.sql | 25 ---- .../20241125021358_add/migration.sql | 11 -- .../20241125021453_add/migration.sql | 2 - .../20241125021534_add/migration.sql | 2 - .../20241125021636_add/migration.sql | 2 - .../20241126142344_test/migration.sql | 30 ----- .../20241126151827_add/migration.sql | 17 --- .../20241126160711_add/migration.sql | 39 ------- .../20241130171204_change/migration.sql | 110 ++++++++++++++++++ .../20241130180253_add/migration.sql | 14 +++ prisma/migrations/migration_lock.toml | 2 +- 16 files changed, 270 insertions(+), 195 deletions(-) create mode 100644 actions/ninja/client.ts create mode 100644 components/ui/checkbox.tsx delete mode 100644 prisma/migrations/20241124133417_add/migration.sql delete mode 100644 prisma/migrations/20241124133512_add/migration.sql delete mode 100644 prisma/migrations/20241125021358_add/migration.sql delete mode 100644 prisma/migrations/20241125021453_add/migration.sql delete mode 100644 prisma/migrations/20241125021534_add/migration.sql delete mode 100644 prisma/migrations/20241125021636_add/migration.sql delete mode 100644 prisma/migrations/20241126142344_test/migration.sql delete mode 100644 prisma/migrations/20241126151827_add/migration.sql delete mode 100644 prisma/migrations/20241126160711_add/migration.sql create mode 100644 prisma/migrations/20241130171204_change/migration.sql create mode 100644 prisma/migrations/20241130180253_add/migration.sql diff --git a/actions/auth-actions.ts b/actions/auth-actions.ts index 76e6901..b824b2d 100644 --- a/actions/auth-actions.ts +++ b/actions/auth-actions.ts @@ -3,10 +3,10 @@ import { authClient } from "@/lib/auth-client"; import prisma from "@/lib/db"; import { signUpFormSchema } from "@/lib/schemas"; +import { headers } from "next/headers"; // import type { User } from "@prisma/client"; import { redirect } from "next/navigation"; import { z } from "zod"; -import { headers } from "next/headers"; const formSchema = z.object({ phoneNumber: z .string() @@ -112,7 +112,7 @@ export async function signup(_actionState: ActionState, formData: FormData) { name: parsedData.data.name, islandId: parsedData.data.island_id, atollId: parsedData.data.atoll_id, - house_name: parsedData.data.house_name, + address: parsedData.data.address, id_card: parsedData.data.id_card, dob: new Date(parsedData.data.dob), role: "USER", diff --git a/actions/ninja/client.ts b/actions/ninja/client.ts new file mode 100644 index 0000000..540e55b --- /dev/null +++ b/actions/ninja/client.ts @@ -0,0 +1,89 @@ +"use server"; +// const raw = { +// group_settings_id: "", +// address1: "", +// city: "F", +// state: "Dharanboodhoo", +// postal_code: "12040", +// country_id: "462", +// address2: "Skyvilla", +// contacts: [ +// { +// first_name: "Abdulla", +// last_name: "Aidhaan", +// email: "", +// phone: "778-0588", +// send_email: false, +// custom_value1: "1971-02-24", +// custom_value2: "A265117", +// custom_value3: "", +// }, +// ], +// }; + +type CreateClientProps = { + group_settings_id: string; + address1: string; + city: string; + state: string; + postal_code: string; + country_id: string; + address2: string; + contacts: Contact; +}; + +type Contact = { + first_name: string; + last_name: string; + email: string; + phone: string; + send_email: boolean; + custom_value1: string; + custom_value2: string; + custom_value3: string; +}; +export async function CreateClient({ + group_settings_id = "", + address1 = "", + city, + state, + postal_code = "", + country_id = "462", + address2, + contacts, +}: CreateClientProps) { + const response = await fetch( + "https://finance-staging.baraveli.dev/api/v1/clients", + { + method: "POST", + headers: { + "Content-Type": "application/json", + "x-api-token": `${process.env.NINJA_API_KEY}`, + }, + body: JSON.stringify({ + group_settings_id, + address1, + city, + state, + postal_code, + country_id, + address2, + contacts: [ + { + first_name: contacts.first_name, + last_name: contacts.last_name, + email: contacts.email || "", + phone: contacts.phone, + send_email: contacts.send_email, + custom_value1: contacts.custom_value1, + custom_value2: contacts.custom_value2, + custom_value3: contacts.custom_value3 || "", + }, + ], + }), + }, + ); + const data = await response.json(); + console.log(data.data.contacts); + return data; +} diff --git a/actions/user-actions.ts b/actions/user-actions.ts index 5367085..7c2c0d1 100644 --- a/actions/user-actions.ts +++ b/actions/user-actions.ts @@ -2,17 +2,21 @@ import prisma from "@/lib/db"; import { revalidatePath } from "next/cache"; +import { CreateClient } from "./ninja/client"; export async function VerifyUser(userId: string) { const user = await prisma.user.findUnique({ where: { id: userId, }, + include: { + atoll: true, + island: true, + }, }); if (!user) { throw new Error("User not found"); } - user.verified = true; await prisma.user.update({ where: { id: userId, @@ -21,5 +25,24 @@ export async function VerifyUser(userId: string) { verified: true, }, }); + await CreateClient({ + group_settings_id: "", + address1: "", + city: user.atoll?.name || "", + state: user.island?.name || "", + postal_code: "", + country_id: "462", + address2: user.address || "", + contacts: { + first_name: user.name?.split(" ")[0] || "", + last_name: user.name?.split(" ")[1] || "", + email: user.email || "", + phone: user.phoneNumber || "", + send_email: false, + custom_value1: user.dob?.toISOString().split("T")[0] || "", + custom_value2: user.id_card || "", + custom_value3: "", + }, + }); revalidatePath("/users"); } diff --git a/components/ui/checkbox.tsx b/components/ui/checkbox.tsx new file mode 100644 index 0000000..c6fdd07 --- /dev/null +++ b/components/ui/checkbox.tsx @@ -0,0 +1,30 @@ +"use client" + +import * as React from "react" +import * as CheckboxPrimitive from "@radix-ui/react-checkbox" +import { Check } from "lucide-react" + +import { cn } from "@/lib/utils" + +const Checkbox = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + + + + + +)) +Checkbox.displayName = CheckboxPrimitive.Root.displayName + +export { Checkbox } diff --git a/prisma/migrations/20241124133417_add/migration.sql b/prisma/migrations/20241124133417_add/migration.sql deleted file mode 100644 index c56e667..0000000 --- a/prisma/migrations/20241124133417_add/migration.sql +++ /dev/null @@ -1,63 +0,0 @@ --- CreateTable -CREATE TABLE "user" ( - "id" TEXT NOT NULL PRIMARY KEY, - "name" TEXT, - "email" TEXT NOT NULL, - "emailVerified" BOOLEAN NOT NULL DEFAULT false, - "firstPaymentDone" BOOLEAN NOT NULL DEFAULT false, - "image" TEXT, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL, - "phoneNumber" TEXT NOT NULL, - "phoneNumberVerified" BOOLEAN NOT NULL DEFAULT false, - "role" TEXT, - "lang" TEXT -); - --- CreateTable -CREATE TABLE "session" ( - "id" TEXT NOT NULL PRIMARY KEY, - "userId" TEXT NOT NULL, - "token" TEXT NOT NULL, - "expiresAt" DATETIME NOT NULL, - "ipAddress" TEXT, - "userAgent" TEXT, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL -); - --- CreateTable -CREATE TABLE "account" ( - "id" TEXT NOT NULL PRIMARY KEY, - "userId" TEXT NOT NULL, - "accountId" TEXT NOT NULL, - "providerId" TEXT NOT NULL, - "accessToken" TEXT, - "refreshToken" TEXT, - "accessTokenExpiresAt" DATETIME, - "refreshTokenExpiresAt" DATETIME, - "scope" TEXT, - "password" TEXT, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL, - "idToken" TEXT -); - --- CreateTable -CREATE TABLE "verification" ( - "id" TEXT NOT NULL PRIMARY KEY, - "identifier" TEXT NOT NULL, - "value" TEXT NOT NULL, - "expiresAt" DATETIME NOT NULL, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL -); - --- CreateIndex -CREATE UNIQUE INDEX "user_email_key" ON "user"("email"); - --- CreateIndex -CREATE UNIQUE INDEX "user_phoneNumber_key" ON "user"("phoneNumber"); - --- CreateIndex -CREATE UNIQUE INDEX "session_token_key" ON "session"("token"); diff --git a/prisma/migrations/20241124133512_add/migration.sql b/prisma/migrations/20241124133512_add/migration.sql deleted file mode 100644 index 74ebe47..0000000 --- a/prisma/migrations/20241124133512_add/migration.sql +++ /dev/null @@ -1,25 +0,0 @@ --- RedefineTables -PRAGMA defer_foreign_keys=ON; -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_user" ( - "id" TEXT NOT NULL PRIMARY KEY, - "name" TEXT, - "email" TEXT NOT NULL, - "emailVerified" BOOLEAN NOT NULL DEFAULT false, - "firstPaymentDone" BOOLEAN NOT NULL DEFAULT false, - "verified" BOOLEAN NOT NULL DEFAULT false, - "image" TEXT, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL, - "phoneNumber" TEXT NOT NULL, - "phoneNumberVerified" BOOLEAN NOT NULL DEFAULT false, - "role" TEXT, - "lang" TEXT -); -INSERT INTO "new_user" ("createdAt", "email", "emailVerified", "firstPaymentDone", "id", "image", "lang", "name", "phoneNumber", "phoneNumberVerified", "role", "updatedAt") SELECT "createdAt", "email", "emailVerified", "firstPaymentDone", "id", "image", "lang", "name", "phoneNumber", "phoneNumberVerified", "role", "updatedAt" FROM "user"; -DROP TABLE "user"; -ALTER TABLE "new_user" RENAME TO "user"; -CREATE UNIQUE INDEX "user_email_key" ON "user"("email"); -CREATE UNIQUE INDEX "user_phoneNumber_key" ON "user"("phoneNumber"); -PRAGMA foreign_keys=ON; -PRAGMA defer_foreign_keys=OFF; diff --git a/prisma/migrations/20241125021358_add/migration.sql b/prisma/migrations/20241125021358_add/migration.sql deleted file mode 100644 index 846e033..0000000 --- a/prisma/migrations/20241125021358_add/migration.sql +++ /dev/null @@ -1,11 +0,0 @@ -/* - Warnings: - - - A unique constraint covering the columns `[id_card]` on the table `user` will be added. If there are existing duplicate values, this will fail. - -*/ --- AlterTable -ALTER TABLE "user" ADD COLUMN "id_card" TEXT; - --- CreateIndex -CREATE UNIQUE INDEX "user_id_card_key" ON "user"("id_card"); diff --git a/prisma/migrations/20241125021453_add/migration.sql b/prisma/migrations/20241125021453_add/migration.sql deleted file mode 100644 index 9f1b532..0000000 --- a/prisma/migrations/20241125021453_add/migration.sql +++ /dev/null @@ -1,2 +0,0 @@ --- AlterTable -ALTER TABLE "user" ADD COLUMN "island" TEXT; diff --git a/prisma/migrations/20241125021534_add/migration.sql b/prisma/migrations/20241125021534_add/migration.sql deleted file mode 100644 index d1b549c..0000000 --- a/prisma/migrations/20241125021534_add/migration.sql +++ /dev/null @@ -1,2 +0,0 @@ --- AlterTable -ALTER TABLE "user" ADD COLUMN "house_name" TEXT; diff --git a/prisma/migrations/20241125021636_add/migration.sql b/prisma/migrations/20241125021636_add/migration.sql deleted file mode 100644 index 33a5b71..0000000 --- a/prisma/migrations/20241125021636_add/migration.sql +++ /dev/null @@ -1,2 +0,0 @@ --- AlterTable -ALTER TABLE "user" ADD COLUMN "dob" DATETIME; diff --git a/prisma/migrations/20241126142344_test/migration.sql b/prisma/migrations/20241126142344_test/migration.sql deleted file mode 100644 index fab4262..0000000 --- a/prisma/migrations/20241126142344_test/migration.sql +++ /dev/null @@ -1,30 +0,0 @@ --- RedefineTables -PRAGMA defer_foreign_keys=ON; -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_user" ( - "id" TEXT NOT NULL PRIMARY KEY, - "name" TEXT, - "email" TEXT, - "emailVerified" BOOLEAN NOT NULL DEFAULT false, - "firstPaymentDone" BOOLEAN NOT NULL DEFAULT false, - "verified" BOOLEAN NOT NULL DEFAULT false, - "island" TEXT, - "house_name" TEXT, - "id_card" TEXT, - "dob" DATETIME, - "image" TEXT, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL, - "phoneNumber" TEXT NOT NULL, - "phoneNumberVerified" BOOLEAN NOT NULL DEFAULT false, - "role" TEXT, - "lang" TEXT -); -INSERT INTO "new_user" ("createdAt", "dob", "email", "emailVerified", "firstPaymentDone", "house_name", "id", "id_card", "image", "island", "lang", "name", "phoneNumber", "phoneNumberVerified", "role", "updatedAt", "verified") SELECT "createdAt", "dob", "email", "emailVerified", "firstPaymentDone", "house_name", "id", "id_card", "image", "island", "lang", "name", "phoneNumber", "phoneNumberVerified", "role", "updatedAt", "verified" FROM "user"; -DROP TABLE "user"; -ALTER TABLE "new_user" RENAME TO "user"; -CREATE UNIQUE INDEX "user_email_key" ON "user"("email"); -CREATE UNIQUE INDEX "user_id_card_key" ON "user"("id_card"); -CREATE UNIQUE INDEX "user_phoneNumber_key" ON "user"("phoneNumber"); -PRAGMA foreign_keys=ON; -PRAGMA defer_foreign_keys=OFF; diff --git a/prisma/migrations/20241126151827_add/migration.sql b/prisma/migrations/20241126151827_add/migration.sql deleted file mode 100644 index ba7a9d6..0000000 --- a/prisma/migrations/20241126151827_add/migration.sql +++ /dev/null @@ -1,17 +0,0 @@ --- CreateTable -CREATE TABLE "Atoll" ( - "id" TEXT NOT NULL PRIMARY KEY, - "name" TEXT NOT NULL, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL -); - --- CreateTable -CREATE TABLE "Island" ( - "id" TEXT NOT NULL PRIMARY KEY, - "atollId" TEXT NOT NULL, - "name" TEXT NOT NULL, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL, - CONSTRAINT "Island_atollId_fkey" FOREIGN KEY ("atollId") REFERENCES "Atoll" ("id") ON DELETE RESTRICT ON UPDATE CASCADE -); diff --git a/prisma/migrations/20241126160711_add/migration.sql b/prisma/migrations/20241126160711_add/migration.sql deleted file mode 100644 index 6e759ee..0000000 --- a/prisma/migrations/20241126160711_add/migration.sql +++ /dev/null @@ -1,39 +0,0 @@ -/* - Warnings: - - - You are about to drop the column `island` on the `user` table. All the data in the column will be lost. - -*/ --- RedefineTables -PRAGMA defer_foreign_keys=ON; -PRAGMA foreign_keys=OFF; -CREATE TABLE "new_user" ( - "id" TEXT NOT NULL PRIMARY KEY, - "name" TEXT, - "email" TEXT, - "emailVerified" BOOLEAN NOT NULL DEFAULT false, - "firstPaymentDone" BOOLEAN NOT NULL DEFAULT false, - "verified" BOOLEAN NOT NULL DEFAULT false, - "house_name" TEXT, - "id_card" TEXT, - "dob" DATETIME, - "image" TEXT, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL, - "phoneNumber" TEXT NOT NULL, - "phoneNumberVerified" BOOLEAN NOT NULL DEFAULT false, - "role" TEXT, - "lang" TEXT, - "atollId" TEXT, - "islandId" TEXT, - CONSTRAINT "user_atollId_fkey" FOREIGN KEY ("atollId") REFERENCES "Atoll" ("id") ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT "user_islandId_fkey" FOREIGN KEY ("islandId") REFERENCES "Island" ("id") ON DELETE SET NULL ON UPDATE CASCADE -); -INSERT INTO "new_user" ("createdAt", "dob", "email", "emailVerified", "firstPaymentDone", "house_name", "id", "id_card", "image", "lang", "name", "phoneNumber", "phoneNumberVerified", "role", "updatedAt", "verified") SELECT "createdAt", "dob", "email", "emailVerified", "firstPaymentDone", "house_name", "id", "id_card", "image", "lang", "name", "phoneNumber", "phoneNumberVerified", "role", "updatedAt", "verified" FROM "user"; -DROP TABLE "user"; -ALTER TABLE "new_user" RENAME TO "user"; -CREATE UNIQUE INDEX "user_email_key" ON "user"("email"); -CREATE UNIQUE INDEX "user_id_card_key" ON "user"("id_card"); -CREATE UNIQUE INDEX "user_phoneNumber_key" ON "user"("phoneNumber"); -PRAGMA foreign_keys=ON; -PRAGMA defer_foreign_keys=OFF; diff --git a/prisma/migrations/20241130171204_change/migration.sql b/prisma/migrations/20241130171204_change/migration.sql new file mode 100644 index 0000000..01ed177 --- /dev/null +++ b/prisma/migrations/20241130171204_change/migration.sql @@ -0,0 +1,110 @@ +-- CreateTable +CREATE TABLE "user" ( + "id" TEXT NOT NULL, + "name" TEXT, + "email" TEXT, + "emailVerified" BOOLEAN NOT NULL DEFAULT false, + "firstPaymentDone" BOOLEAN NOT NULL DEFAULT false, + "verified" BOOLEAN NOT NULL DEFAULT false, + "address" TEXT, + "id_card" TEXT, + "dob" TIMESTAMP(3), + "image" TEXT, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + "phoneNumber" TEXT NOT NULL, + "phoneNumberVerified" BOOLEAN NOT NULL DEFAULT false, + "role" TEXT, + "lang" TEXT, + "atollId" TEXT, + "islandId" TEXT, + + CONSTRAINT "user_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "session" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "token" TEXT NOT NULL, + "expiresAt" TIMESTAMP(3) NOT NULL, + "ipAddress" TEXT, + "userAgent" TEXT, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "session_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "account" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "accountId" TEXT NOT NULL, + "providerId" TEXT NOT NULL, + "accessToken" TEXT, + "refreshToken" TEXT, + "accessTokenExpiresAt" TIMESTAMP(3), + "refreshTokenExpiresAt" TIMESTAMP(3), + "scope" TEXT, + "password" TEXT, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + "idToken" TEXT, + + CONSTRAINT "account_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "verification" ( + "id" TEXT NOT NULL, + "identifier" TEXT NOT NULL, + "value" TEXT NOT NULL, + "expiresAt" TIMESTAMP(3) NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "verification_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Atoll" ( + "id" TEXT NOT NULL, + "name" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "Atoll_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Island" ( + "id" TEXT NOT NULL, + "atollId" TEXT NOT NULL, + "name" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "Island_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "user_email_key" ON "user"("email"); + +-- CreateIndex +CREATE UNIQUE INDEX "user_id_card_key" ON "user"("id_card"); + +-- CreateIndex +CREATE UNIQUE INDEX "user_phoneNumber_key" ON "user"("phoneNumber"); + +-- CreateIndex +CREATE UNIQUE INDEX "session_token_key" ON "session"("token"); + +-- AddForeignKey +ALTER TABLE "user" ADD CONSTRAINT "user_atollId_fkey" FOREIGN KEY ("atollId") REFERENCES "Atoll"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "user" ADD CONSTRAINT "user_islandId_fkey" FOREIGN KEY ("islandId") REFERENCES "Island"("id") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Island" ADD CONSTRAINT "Island_atollId_fkey" FOREIGN KEY ("atollId") REFERENCES "Atoll"("id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/migrations/20241130180253_add/migration.sql b/prisma/migrations/20241130180253_add/migration.sql new file mode 100644 index 0000000..b153ecb --- /dev/null +++ b/prisma/migrations/20241130180253_add/migration.sql @@ -0,0 +1,14 @@ +-- CreateTable +CREATE TABLE "Device" ( + "id" TEXT NOT NULL, + "name" TEXT NOT NULL, + "mac" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + "userId" TEXT, + + CONSTRAINT "Device_pkey" PRIMARY KEY ("id") +); + +-- AddForeignKey +ALTER TABLE "Device" ADD CONSTRAINT "Device_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml index e5e5c47..fbffa92 100644 --- a/prisma/migrations/migration_lock.toml +++ b/prisma/migrations/migration_lock.toml @@ -1,3 +1,3 @@ # Please do not edit this file manually # It should be added in your version-control system (i.e. Git) -provider = "sqlite" \ No newline at end of file +provider = "postgresql" \ No newline at end of file