This commit is contained in:
jane 2022-04-10 12:02:48 -04:00
parent 83bc981152
commit d369880579
84 changed files with 1946 additions and 20068 deletions

View file

@ -1,39 +0,0 @@
-- CreateTable
CREATE TABLE "User" (
"id" TEXT NOT NULL,
"email" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "User_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Password" (
"hash" TEXT NOT NULL,
"userId" TEXT NOT NULL
);
-- CreateTable
CREATE TABLE "Note" (
"id" TEXT NOT NULL,
"title" TEXT NOT NULL,
"body" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"userId" TEXT NOT NULL,
CONSTRAINT "Note_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
-- CreateIndex
CREATE UNIQUE INDEX "Password_userId_key" ON "Password"("userId");
-- AddForeignKey
ALTER TABLE "Password" ADD CONSTRAINT "Password_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Note" ADD CONSTRAINT "Note_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View file

@ -1,42 +0,0 @@
/*
Warnings:
- You are about to drop the column `email` on the `User` table. All the data in the column will be lost.
- You are about to drop the `Note` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `Password` table. If the table is not empty, all the data it contains will be lost.
- A unique constraint covering the columns `[discord_id]` on the table `User` will be added. If there are existing duplicate values, this will fail.
*/
-- DropForeignKey
ALTER TABLE "Note" DROP CONSTRAINT "Note_userId_fkey";
-- DropForeignKey
ALTER TABLE "Password" DROP CONSTRAINT "Password_userId_fkey";
-- DropIndex
DROP INDEX "User_email_key";
-- AlterTable
ALTER TABLE "User" DROP COLUMN "email",
ADD COLUMN "border_id" TEXT,
ADD COLUMN "discord_id" TEXT;
-- DropTable
DROP TABLE "Note";
-- DropTable
DROP TABLE "Password";
-- CreateTable
CREATE TABLE "Border" (
"id" TEXT NOT NULL,
"filename" TEXT NOT NULL,
CONSTRAINT "Border_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "Border_filename_key" ON "Border"("filename");
-- CreateIndex
CREATE UNIQUE INDEX "User_discord_id_key" ON "User"("discord_id");

View file

@ -1,3 +0,0 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "postgresql"

View file

@ -1,33 +1,11 @@
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
model User {
id String @id @default(cuid())
discord_id String? @unique
border_id String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model DiscordUser {
id String @id @default(cuid())
discord_id String @unique
access_token String?
refresh_token String?
expires DateTime?
username String?
discriminator String?
}
model Border {
id String @id @default(cuid())
filename String @unique
}

View file

@ -1,31 +0,0 @@
import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();
async function seed() {
const discord_id = "123601647258697730";
const border_id = 'test';
// cleanup the existing database
await prisma.user.delete({ where: { discord_id } }).catch(() => {
// no worries if it doesn't exist yet
});
const user = await prisma.user.create({
data: {
discord_id,
border_id
},
});
console.log(`Database has been seeded. 🌱`);
}
seed()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});