init
This commit is contained in:
54
backend/prisma/migrations/20260507211134_init/migration.sql
Normal file
54
backend/prisma/migrations/20260507211134_init/migration.sql
Normal file
@@ -0,0 +1,54 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "User" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"username" TEXT NOT NULL,
|
||||
"email" TEXT NOT NULL,
|
||||
"password" TEXT NOT NULL,
|
||||
"type" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "User_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "UserOferta" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"userId" INTEGER NOT NULL,
|
||||
"ofertaId" INTEGER NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "UserOferta_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Oferta" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"titulo" TEXT NOT NULL,
|
||||
"empresa" TEXT NOT NULL,
|
||||
"ubicacion" TEXT NOT NULL,
|
||||
"salario" TEXT NOT NULL DEFAULT '0',
|
||||
"contrato" TEXT NOT NULL,
|
||||
"descripcion" TEXT NOT NULL,
|
||||
"url" TEXT NOT NULL,
|
||||
"authorId" INTEGER NOT NULL,
|
||||
|
||||
CONSTRAINT "Oferta_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "User_username_key" ON "User"("username");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "UserOferta_userId_ofertaId_key" ON "UserOferta"("userId", "ofertaId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "UserOferta" ADD CONSTRAINT "UserOferta_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "UserOferta" ADD CONSTRAINT "UserOferta_ofertaId_fkey" FOREIGN KEY ("ofertaId") REFERENCES "Oferta"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Oferta" ADD CONSTRAINT "Oferta_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
3
backend/prisma/migrations/migration_lock.toml
Normal file
3
backend/prisma/migrations/migration_lock.toml
Normal 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"
|
||||
53
backend/prisma/schema.prisma
Normal file
53
backend/prisma/schema.prisma
Normal file
@@ -0,0 +1,53 @@
|
||||
// This is your Prisma schema file,
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
||||
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model User {
|
||||
id Int @id @default(autoincrement())
|
||||
username String @unique
|
||||
email String @unique
|
||||
password String
|
||||
type String
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
ofertas Oferta[]
|
||||
postulaciones UserOferta[]
|
||||
}
|
||||
|
||||
model UserOferta {
|
||||
id Int @id @default(autoincrement())
|
||||
userId Int
|
||||
ofertaId Int
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
oferta Oferta @relation(fields: [ofertaId], references: [id])
|
||||
|
||||
@@unique([userId, ofertaId])
|
||||
}
|
||||
|
||||
model Oferta {
|
||||
id Int @id @default(autoincrement())
|
||||
titulo String
|
||||
empresa String
|
||||
ubicacion String
|
||||
salario String @default("0")
|
||||
contrato String
|
||||
descripcion String
|
||||
url String
|
||||
authorId Int
|
||||
|
||||
author User @relation(fields: [authorId], references: [id])
|
||||
candidatos UserOferta[]
|
||||
}
|
||||
Reference in New Issue
Block a user