From 70e009ddf7722785317ff3547310267dcf81ecf4 Mon Sep 17 00:00:00 2001 From: Pablo Fernandez Date: Tue, 2 Jan 2024 10:34:49 +0000 Subject: [PATCH] user table --- .../20240101221505_user_table/migration.sql | 14 +++++++++++ .../20240101221607_add_domain/migration.sql | 25 +++++++++++++++++++ prisma/schema.prisma | 12 +++++++++ 3 files changed, 51 insertions(+) create mode 100644 prisma/migrations/20240101221505_user_table/migration.sql create mode 100644 prisma/migrations/20240101221607_add_domain/migration.sql diff --git a/prisma/migrations/20240101221505_user_table/migration.sql b/prisma/migrations/20240101221505_user_table/migration.sql new file mode 100644 index 0000000..77e8c73 --- /dev/null +++ b/prisma/migrations/20240101221505_user_table/migration.sql @@ -0,0 +1,14 @@ +-- CreateTable +CREATE TABLE "User" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "username" TEXT NOT NULL, + "password" TEXT NOT NULL, + "email" TEXT NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "deletedAt" DATETIME, + "pubkey" TEXT NOT NULL +); + +-- CreateIndex +CREATE UNIQUE INDEX "User_username_key" ON "User"("username"); diff --git a/prisma/migrations/20240101221607_add_domain/migration.sql b/prisma/migrations/20240101221607_add_domain/migration.sql new file mode 100644 index 0000000..76b7db2 --- /dev/null +++ b/prisma/migrations/20240101221607_add_domain/migration.sql @@ -0,0 +1,25 @@ +/* + Warnings: + + - Added the required column `domain` to the `User` table without a default value. This is not possible if the table is not empty. + +*/ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_User" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "username" TEXT NOT NULL, + "domain" TEXT NOT NULL, + "password" TEXT NOT NULL, + "email" TEXT NOT NULL, + "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + "deletedAt" DATETIME, + "pubkey" TEXT NOT NULL +); +INSERT INTO "new_User" ("createdAt", "deletedAt", "email", "id", "password", "pubkey", "updatedAt", "username") SELECT "createdAt", "deletedAt", "email", "id", "password", "pubkey", "updatedAt", "username" FROM "User"; +DROP TABLE "User"; +ALTER TABLE "new_User" RENAME TO "User"; +CREATE UNIQUE INDEX "User_username_key" ON "User"("username"); +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index e4d1fbd..4d4ddd9 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -43,6 +43,18 @@ model Key { pubkey String } +model User { + id Int @id @default(autoincrement()) + username String @unique + domain String + password String + email String + createdAt DateTime @default(now()) + updatedAt DateTime @default(now()) @updatedAt + deletedAt DateTime? + pubkey String +} + model SigningCondition { id Int @id @default(autoincrement()) method String?