Initial commit in this repository

This commit is contained in:
Rapturate
2026-04-27 22:16:17 -04:00
commit 68e7058ca4
64 changed files with 20817 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
-- CreateTable
CREATE TABLE "users" (
"id" SERIAL NOT NULL,
"username" TEXT NOT NULL,
"password" TEXT NOT NULL,
CONSTRAINT "users_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "ideas" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"description" TEXT NOT NULL,
"date_created" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"user_id" INTEGER NOT NULL,
CONSTRAINT "ideas_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "projects" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"description" TEXT NOT NULL,
"date_created" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"user_id" INTEGER NOT NULL,
CONSTRAINT "projects_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "materials" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"description" TEXT NOT NULL,
"source" TEXT NOT NULL,
"author" TEXT NOT NULL,
"text" TEXT NOT NULL,
"project_id" INTEGER NOT NULL,
CONSTRAINT "materials_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "files" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"file" BYTEA NOT NULL,
"project_id" INTEGER NOT NULL,
CONSTRAINT "files_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "users_username_key" ON "users"("username");
-- CreateIndex
CREATE INDEX "ideas_user_id_idx" ON "ideas"("user_id");
-- CreateIndex
CREATE INDEX "projects_user_id_idx" ON "projects"("user_id");
-- CreateIndex
CREATE INDEX "materials_project_id_idx" ON "materials"("project_id");
-- CreateIndex
CREATE INDEX "files_project_id_idx" ON "files"("project_id");
-- AddForeignKey
ALTER TABLE "ideas" ADD CONSTRAINT "ideas_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "projects" ADD CONSTRAINT "projects_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "materials" ADD CONSTRAINT "materials_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "projects"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "files" ADD CONSTRAINT "files_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "projects"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@@ -0,0 +1,10 @@
/*
Warnings:
- Added the required column `mimeType` to the `files` table without a default value. This is not possible if the table is not empty.
- Added the required column `size` to the `files` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "files" ADD COLUMN "mimeType" TEXT NOT NULL,
ADD COLUMN "size" INTEGER NOT NULL;

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"

71
prisma/schema.prisma Normal file
View File

@@ -0,0 +1,71 @@
generator client {
provider = "prisma-client-js"
output = "../src/generated/prisma.js"
}
datasource db {
provider = "postgresql"
}
model User {
id Int @id @default(autoincrement())
username String @unique
password String
ideas Idea[]
projects Project[]
@@map("users")
}
model Idea {
id Int @id @default(autoincrement())
name String
description String
date_created DateTime @default(now()) @map("date_created")
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId Int @map("user_id")
@@index([userId])
@@map("ideas")
}
model Project {
id Int @id @default(autoincrement())
name String
description String
date_created DateTime @default(now()) @map("date_created")
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId Int @map("user_id")
materials Material[]
files File[]
@@index([userId])
@@map("projects")
}
model Material {
id Int @id @default(autoincrement())
name String
description String
source String
author String
text String
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
projectId Int @map("project_id")
@@index([projectId])
@@map("materials")
}
model File {
id Int @id @default(autoincrement())
name String
file Bytes
size Int
mimeType String
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
projectId Int @map("project_id")
@@index([projectId])
@@map("files")
}

102
prisma/seed.js Normal file
View File

@@ -0,0 +1,102 @@
import bcrypt from 'bcrypt';
import 'dotenv/config';
import prisma from '../src/config/db.js';
try {
await prisma.$queryRaw`TRUNCATE users, ideas, projects, materials, files RESTART IDENTITY CASCADE;`;
// Create users
const usersData = [
{ username: 'alice_dev', password: 'alice1234' },
{ username: 'bob_maker', password: 'bob1234' },
{ username: 'charlie_creator', password: 'charlie1234' },
];
const users = [];
for (const userData of usersData) {
const hashedPassword = await bcrypt.hash(userData.password, 10);
const user = await prisma.user.create({
data: {
username: userData.username,
password: hashedPassword,
},
});
users.push(user);
}
// Create ideas for each user
for (const user of users) {
await prisma.idea.createMany({
data: [
{
name: 'AI-Powered Task Manager',
description:
'A web app that uses AI to prioritize tasks intelligently based on user patterns.',
userId: user.id,
},
{
name: 'Community Recipe Hub',
description:
'A platform where users can share, rate, and discover recipes from around the world.',
userId: user.id,
},
{
name: 'Real-time Collaboration Tool',
description:
'A tool for teams to brainstorm and collaborate in real-time with visual whiteboarding.',
userId: user.id,
},
],
});
}
// Create projects with materials for each user
for (const user of users) {
const project = await prisma.project.create({
data: {
name: `${user.username}'s Innovation Lab`,
description: `Main project workspace for ${user.username} to develop and prototype ideas.`,
userId: user.id,
},
});
// Add materials to the project
await prisma.material.createMany({
data: [
{
name: 'Research Paper on UX Design',
description: 'Key findings on modern UI/UX best practices.',
source: 'Nielsen Norman Group',
author: 'Don Norman',
text: 'User experience encompasses all aspects of the end-users interaction with the company, its services, and its products.',
projectId: project.id,
},
{
name: 'API Documentation Reference',
description: 'Technical specifications for third-party integrations.',
source: 'OpenAI API Docs',
author: 'OpenAI Team',
text: 'The API provides access to state-of-the-art language models for various NLP tasks.',
projectId: project.id,
},
{
name: 'Project Budget Template',
description: 'Financial planning and resource allocation framework.',
source: 'Internal Resources',
author: 'Finance Department',
text: 'Ensure all project expenses are tracked and approved according to company policy.',
projectId: project.id,
},
],
});
}
console.log('Seed completed successfully!');
} catch (error) {
console.error('Seed failed:', error);
} finally {
await prisma.$disconnect();
}