feat: astro test

This commit is contained in:
trafficlunar 2026-04-16 22:32:08 +01:00
parent df6e31ba89
commit 84144c383c
262 changed files with 18993 additions and 2655 deletions

View file

@ -0,0 +1,90 @@
-- CreateTable
CREATE TABLE "users" (
"id" SERIAL NOT NULL,
"username" TEXT,
"name" TEXT NOT NULL,
"email" TEXT NOT NULL,
"emailVerified" TIMESTAMP(3),
"image" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"usernameUpdatedAt" TIMESTAMP(3),
CONSTRAINT "users_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "accounts" (
"userId" INTEGER NOT NULL,
"type" TEXT NOT NULL,
"provider" TEXT NOT NULL,
"providerAccountId" TEXT NOT NULL,
"refresh_token" TEXT,
"access_token" TEXT,
"expires_at" INTEGER,
"token_type" TEXT,
"scope" TEXT,
"id_token" TEXT,
"session_state" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "accounts_pkey" PRIMARY KEY ("provider","providerAccountId")
);
-- CreateTable
CREATE TABLE "sessions" (
"sessionToken" TEXT NOT NULL,
"userId" INTEGER NOT NULL,
"expires" TIMESTAMP(3) NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL
);
-- CreateTable
CREATE TABLE "miis" (
"id" SERIAL NOT NULL,
"userId" INTEGER NOT NULL,
"name" VARCHAR(64) NOT NULL,
"imageCount" INTEGER NOT NULL DEFAULT 0,
"tags" TEXT[],
"firstName" TEXT NOT NULL,
"lastName" TEXT NOT NULL,
"islandName" TEXT NOT NULL,
"allowedCopying" BOOLEAN NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "miis_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "likes" (
"userId" INTEGER NOT NULL,
"miiId" INTEGER NOT NULL,
CONSTRAINT "likes_pkey" PRIMARY KEY ("userId","miiId")
);
-- CreateIndex
CREATE UNIQUE INDEX "users_username_key" ON "users"("username");
-- CreateIndex
CREATE UNIQUE INDEX "users_email_key" ON "users"("email");
-- CreateIndex
CREATE UNIQUE INDEX "sessions_sessionToken_key" ON "sessions"("sessionToken");
-- AddForeignKey
ALTER TABLE "accounts" ADD CONSTRAINT "accounts_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "sessions" ADD CONSTRAINT "sessions_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "miis" ADD CONSTRAINT "miis_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "likes" ADD CONSTRAINT "likes_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "likes" ADD CONSTRAINT "likes_miiId_fkey" FOREIGN KEY ("miiId") REFERENCES "miis"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View file

@ -0,0 +1,25 @@
-- CreateEnum
CREATE TYPE "ReportType" AS ENUM ('MII', 'USER');
-- CreateEnum
CREATE TYPE "ReportReason" AS ENUM ('INAPPROPRIATE', 'SPAM', 'COPYRIGHT', 'OTHER');
-- CreateEnum
CREATE TYPE "ReportStatus" AS ENUM ('OPEN', 'RESOLVED', 'DISMISSED');
-- CreateTable
CREATE TABLE "reports" (
"id" SERIAL NOT NULL,
"reportType" "ReportType" NOT NULL,
"status" "ReportStatus" NOT NULL DEFAULT 'OPEN',
"targetId" INTEGER NOT NULL,
"reason" "ReportReason" NOT NULL,
"reasonNotes" TEXT,
"authorId" INTEGER,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "reports_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "reports" ADD CONSTRAINT "reports_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View file

@ -0,0 +1,5 @@
-- CreateEnum
CREATE TYPE "MiiGender" AS ENUM ('MALE', 'FEMALE');
-- AlterTable
ALTER TABLE "miis" ADD COLUMN "gender" "MiiGender";

View file

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "miis" ADD COLUMN "description" VARCHAR(256);

View file

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "users" ADD COLUMN "imageUpdatedAt" TIMESTAMP(3);

View file

@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE "reports" ADD COLUMN "creatorId" INTEGER;
-- AddForeignKey
ALTER TABLE "reports" ADD CONSTRAINT "reports_creatorId_fkey" FOREIGN KEY ("creatorId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View file

@ -0,0 +1,36 @@
-- CreateEnum
CREATE TYPE "PunishmentType" AS ENUM ('WARNING', 'TEMP_EXILE', 'PERM_EXILE');
-- AlterTable
ALTER TABLE "miis" ADD COLUMN "punishmentId" INTEGER;
-- CreateTable
CREATE TABLE "mii_punishments" (
"punishmentId" INTEGER NOT NULL,
"miiId" INTEGER NOT NULL,
"reason" TEXT NOT NULL,
CONSTRAINT "mii_punishments_pkey" PRIMARY KEY ("punishmentId","miiId")
);
-- CreateTable
CREATE TABLE "punishments" (
"id" SERIAL NOT NULL,
"userId" INTEGER NOT NULL,
"type" "PunishmentType" NOT NULL,
"notes" TEXT NOT NULL,
"reasons" TEXT[],
"expiresAt" TIMESTAMP(3),
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "punishments_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "mii_punishments" ADD CONSTRAINT "mii_punishments_punishmentId_fkey" FOREIGN KEY ("punishmentId") REFERENCES "punishments"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "mii_punishments" ADD CONSTRAINT "mii_punishments_miiId_fkey" FOREIGN KEY ("miiId") REFERENCES "miis"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "punishments" ADD CONSTRAINT "punishments_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View file

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "punishments" ADD COLUMN "returned" BOOLEAN NOT NULL DEFAULT false;

View file

@ -0,0 +1,9 @@
-- CreateEnum
CREATE TYPE "public"."MiiPlatform" AS ENUM ('SWITCH', 'THREE_DS');
-- AlterTable
ALTER TABLE "public"."miis" ADD COLUMN "platform" "public"."MiiPlatform" NOT NULL DEFAULT 'THREE_DS',
ALTER COLUMN "firstName" DROP NOT NULL,
ALTER COLUMN "lastName" DROP NOT NULL,
ALTER COLUMN "islandName" DROP NOT NULL,
ALTER COLUMN "allowedCopying" DROP NOT NULL;

View file

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "users" ADD COLUMN "description" VARCHAR(256);

View file

@ -0,0 +1,2 @@
-- AlterEnum
ALTER TYPE "MiiGender" ADD VALUE 'NONBINARY';

View file

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "miis" ADD COLUMN "instructions" JSONB;

View file

@ -0,0 +1,16 @@
/*
Warnings:
- You are about to drop the column `username` on the `users` table. All the data in the column will be lost.
- You are about to drop the column `usernameUpdatedAt` on the `users` table. All the data in the column will be lost.
*/
-- DropIndex
DROP INDEX "users_username_key";
-- AlterTable
ALTER TABLE "miis" ALTER COLUMN "allowedCopying" DROP NOT NULL;
-- AlterTable
ALTER TABLE "users" DROP COLUMN "username",
DROP COLUMN "usernameUpdatedAt";

View file

@ -0,0 +1,2 @@
-- AlterEnum
ALTER TYPE "ReportReason" ADD VALUE 'BAD_QUALITY';

View file

@ -0,0 +1,5 @@
-- CreateEnum
CREATE TYPE "MiiMakeup" AS ENUM ('FULL', 'PARTIAL', 'NONE');
-- AlterTable
ALTER TABLE "miis" ADD COLUMN "makeup" "MiiMakeup";

View file

@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE "miis" ALTER COLUMN "description" SET DATA TYPE VARCHAR(512);
-- AlterTable
ALTER TABLE "users" ALTER COLUMN "description" SET DATA TYPE VARCHAR(512);

View file

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "miis" ADD COLUMN "quarantined" BOOLEAN NOT NULL DEFAULT false;

View file

@ -0,0 +1,26 @@
-- CreateIndex
CREATE INDEX "likes_miiId_idx" ON "likes"("miiId");
-- CreateIndex
CREATE INDEX "miis_tags_idx" ON "miis" USING GIN ("tags");
-- CreateIndex
CREATE INDEX "miis_createdAt_idx" ON "miis"("createdAt");
-- CreateIndex
CREATE INDEX "miis_quarantined_createdAt_idx" ON "miis"("quarantined", "createdAt" DESC);
-- CreateIndex
CREATE INDEX "miis_platform_createdAt_idx" ON "miis"("platform", "createdAt" DESC);
-- CreateIndex
CREATE INDEX "miis_userId_createdAt_idx" ON "miis"("userId", "createdAt" DESC);
-- CreateIndex
CREATE INDEX "miis_gender_idx" ON "miis"("gender");
-- CreateIndex
CREATE INDEX "miis_makeup_idx" ON "miis"("makeup");
-- CreateIndex
CREATE INDEX "miis_quarantined_id_idx" ON "miis"("quarantined", "id");

View file

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "miis" ADD COLUMN "in_queue" BOOLEAN NOT NULL DEFAULT false;

View file

@ -0,0 +1,14 @@
/*
Warnings:
- The values [COPYRIGHT] on the enum `ReportReason` will be removed. If these variants are still used in the database, this will fail.
*/
-- AlterEnum
BEGIN;
CREATE TYPE "ReportReason_new" AS ENUM ('INAPPROPRIATE', 'SPAM', 'BAD_QUALITY', 'OTHER');
ALTER TABLE "reports" ALTER COLUMN "reason" TYPE "ReportReason_new" USING ("reason"::text::"ReportReason_new");
ALTER TYPE "ReportReason" RENAME TO "ReportReason_old";
ALTER TYPE "ReportReason_new" RENAME TO "ReportReason";
DROP TYPE "public"."ReportReason_old";
COMMIT;

View file

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "miis" ADD COLUMN "youtubeId" TEXT;

View file

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

View file

@ -0,0 +1,211 @@
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
name String
email String @unique
emailVerified DateTime?
image String?
description String? @db.VarChar(512)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
imageUpdatedAt DateTime?
accounts Account[]
sessions Session[]
miis Mii[]
likes Like[]
reportsAuthored Report[] @relation("ReportAuthor")
reports Report[] @relation("ReportTargetCreator")
punishments Punishment[]
@@map("users")
}
model Account {
userId Int
type String
provider String
providerAccountId String
refresh_token String?
access_token String?
expires_at Int?
token_type String?
scope String?
id_token String?
session_state String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@id([provider, providerAccountId])
@@map("accounts")
}
model Session {
sessionToken String @unique
userId Int
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@map("sessions")
}
model Mii {
id Int @id @default(autoincrement())
userId Int
name String @db.VarChar(64)
imageCount Int @default(0)
tags String[]
description String? @db.VarChar(512)
platform MiiPlatform @default(THREE_DS)
quarantined Boolean @default(false)
in_queue Boolean @default(false)
instructions Json?
youtubeId String?
gender MiiGender?
makeup MiiMakeup?
firstName String?
lastName String?
islandName String?
allowedCopying Boolean?
createdAt DateTime @default(now())
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
likedBy Like[]
punishmentId Int?
punishments MiiPunishment[]
@@index([tags], type: Gin)
@@index([createdAt])
@@index([quarantined, createdAt(sort: Desc)])
@@index([platform, createdAt(sort: Desc)])
@@index([userId, createdAt(sort: Desc)])
@@index([gender])
@@index([makeup])
@@index([quarantined, id])
@@map("miis")
}
model Like {
userId Int
miiId Int
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
mii Mii @relation(fields: [miiId], references: [id], onDelete: Cascade)
@@id([userId, miiId])
@@index([miiId])
@@map("likes")
}
model Report {
id Int @id @default(autoincrement())
reportType ReportType
status ReportStatus @default(OPEN)
targetId Int
reason ReportReason
reasonNotes String?
createdAt DateTime @default(now())
// note: this refers to the person who made the report
authorId Int?
author User? @relation("ReportAuthor", fields: [authorId], references: [id])
creatorId Int?
creator User? @relation("ReportTargetCreator", fields: [creatorId], references: [id])
@@map("reports")
}
model MiiPunishment {
punishmentId Int
miiId Int
reason String
punishment Punishment @relation(fields: [punishmentId], references: [id], onDelete: Cascade)
mii Mii @relation(fields: [miiId], references: [id], onDelete: Cascade)
@@id([punishmentId, miiId])
@@map("mii_punishments")
}
model Punishment {
id Int @id @default(autoincrement())
userId Int
type PunishmentType
returned Boolean @default(false)
notes String
reasons String[]
violatingMiis MiiPunishment[]
expiresAt DateTime?
createdAt DateTime @default(now())
user User @relation(fields: [userId], references: [id])
@@map("punishments")
}
enum MiiPlatform {
SWITCH
THREE_DS // can't start with a number
}
enum MiiGender {
MALE
FEMALE
NONBINARY
}
enum MiiMakeup {
FULL
PARTIAL
NONE
}
enum ReportType {
MII
USER
}
enum ReportReason {
INAPPROPRIATE
SPAM
BAD_QUALITY
OTHER
}
enum ReportStatus {
OPEN
RESOLVED
DISMISSED
}
enum PunishmentType {
WARNING
TEMP_EXILE
PERM_EXILE
}