initializing database models, migrations and ORM with Prisma
This commit is contained in:
50
prisma/migrations/20240219094852_init/migration.sql
Normal file
50
prisma/migrations/20240219094852_init/migration.sql
Normal file
@@ -0,0 +1,50 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "AgentTool" AS ENUM ('DUCK_DUCK_GO_SEARCH', 'PUBMED', 'PYTHON_REPL', 'SEMANTIC_SCHOLER', 'STACK_EXCHANGE', 'WIKIDATA', 'WIKIPEDIA', 'YAHOO_FINANCE', 'YUOUTUBE_SEARCH');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "MissionProcess" AS ENUM ('SEQUENTIAL', 'HIERARCHICAL');
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Agent" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"role" TEXT NOT NULL,
|
||||
"goal" TEXT NOT NULL,
|
||||
"backstory" TEXT,
|
||||
"tools" "AgentTool"[] DEFAULT ARRAY[]::"AgentTool"[],
|
||||
"allowDelegation" BOOLEAN NOT NULL DEFAULT false,
|
||||
"verbose" BOOLEAN NOT NULL DEFAULT false,
|
||||
"image" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "Agent_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Mission" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"tasks" JSONB NOT NULL,
|
||||
"verbose" BOOLEAN NOT NULL,
|
||||
"process" "MissionProcess" NOT NULL,
|
||||
"result" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "Mission_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "AgentInMission" (
|
||||
"agentId" INTEGER NOT NULL,
|
||||
"missionId" INTEGER NOT NULL,
|
||||
"assignedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "AgentInMission_pkey" PRIMARY KEY ("agentId","missionId")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "AgentInMission" ADD CONSTRAINT "AgentInMission_agentId_fkey" FOREIGN KEY ("agentId") REFERENCES "Agent"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "AgentInMission" ADD CONSTRAINT "AgentInMission_missionId_fkey" FOREIGN KEY ("missionId") REFERENCES "Mission"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
3
prisma/migrations/migration_lock.toml
Normal file
3
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 (i.e. Git)
|
||||
provider = "postgresql"
|
||||
67
prisma/schema.prisma
Normal file
67
prisma/schema.prisma
Normal file
@@ -0,0 +1,67 @@
|
||||
// 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"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
enum AgentTool {
|
||||
DUCK_DUCK_GO_SEARCH
|
||||
PUBMED
|
||||
PYTHON_REPL
|
||||
SEMANTIC_SCHOLER
|
||||
STACK_EXCHANGE
|
||||
WIKIDATA
|
||||
WIKIPEDIA
|
||||
YAHOO_FINANCE
|
||||
YUOUTUBE_SEARCH
|
||||
}
|
||||
|
||||
model Agent {
|
||||
id Int @id @default(autoincrement())
|
||||
role String
|
||||
goal String
|
||||
backstory String?
|
||||
tools AgentTool[] @default([])
|
||||
allowDelegation Boolean @default(false)
|
||||
verbose Boolean @default(false)
|
||||
image String?
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
missions AgentInMission[]
|
||||
}
|
||||
|
||||
enum MissionProcess {
|
||||
SEQUENTIAL
|
||||
HIERARCHICAL
|
||||
}
|
||||
|
||||
model Mission {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
crew AgentInMission[]
|
||||
tasks Json
|
||||
verbose Boolean
|
||||
process MissionProcess
|
||||
result String
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model AgentInMission {
|
||||
agent Agent @relation(fields: [agentId], references: [id])
|
||||
agentId Int // relation scalar field (used in the `@relation` attribute above)
|
||||
mission Mission @relation(fields: [missionId], references: [id])
|
||||
missionId Int // relation scalar field (used in the `@relation` attribute above)
|
||||
assignedAt DateTime @default(now())
|
||||
|
||||
@@id([agentId, missionId])
|
||||
}
|
||||
Reference in New Issue
Block a user