Removing Prisma and Grapql-nestjs-prisma resolvers (#2574)

* Some cleaning

* Fix seeds

* Fix all sign in, sign up flow and apiKey optimistic rendering

* Fix
This commit is contained in:
Charles Bochet
2023-11-19 18:25:47 +01:00
committed by GitHub
parent 18dac1a2b6
commit f5e1d7825a
616 changed files with 2220 additions and 23073 deletions

View File

@ -1,4 +0,0 @@
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
export default prisma;

View File

@ -1,15 +0,0 @@
import { PrismaClient } from '@prisma/client';
import { mockDeep, mockReset, DeepMockProxy } from 'jest-mock-extended';
import prisma from './client';
jest.mock('./client', () => ({
__esModule: true,
default: mockDeep<PrismaClient>(),
}));
beforeEach(() => {
mockReset(prismaMock);
});
export const prismaMock = prisma as unknown as DeepMockProxy<PrismaClient>;

View File

@ -1,344 +0,0 @@
import {
Command,
CommandRunner,
InquirerService,
Option,
} from 'nest-commander';
import isEqual from 'lodash.isequal';
import { PrismaService } from 'src/database/prisma.service';
import peopleSeed from 'src/core/person/seed-data/people.json';
import companiesSeed from 'src/core/company/seed-data/companies.json';
import pipelineStagesSeed from 'src/core/pipeline/seed-data/pipeline-stages.json';
import pipelinesSeed from 'src/core/pipeline/seed-data/sales-pipeline.json';
import { WorkspaceService } from 'src/core/workspace/services/workspace.service';
interface DataCleanInactiveOptions {
days?: number;
sameAsSeedDays?: number;
dryRun?: boolean;
confirmation?: boolean;
workspaceId?: string;
}
interface ActivityReport {
displayName: string;
maxUpdatedAt: string;
inactiveDays: number;
sameAsSeed: boolean;
}
interface DataCleanResults {
[key: string]: ActivityReport;
}
const formattedPipelineStagesSeed = pipelineStagesSeed.map((pipelineStage) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { position, ...rest } = pipelineStage;
return rest;
});
@Command({
name: 'workspaces:clean-inactive',
description: 'Clean inactive workspaces from the public database schema',
})
export class DataCleanInactiveCommand extends CommandRunner {
constructor(
private readonly prismaService: PrismaService,
private readonly workspaceService: WorkspaceService,
private readonly inquiererService: InquirerService,
) {
super();
}
@Option({
flags: '-w, --workspaceId [workspace id]',
description: 'Specific workspaceId to apply cleaning',
})
parseWorkspace(val: string): string {
return val;
}
@Option({
flags: '-d, --days [inactive days threshold]',
description: 'Inactive days threshold',
defaultValue: 60,
})
parseDays(val: string): number {
return Number(val);
}
@Option({
flags: '-s, --same-as-seed-days [same as seed days threshold]',
description: 'Same as seed days threshold',
defaultValue: 10,
})
parseSameAsSeedDays(val: string): number {
return Number(val);
}
@Option({
flags: '--dry-run [dry run]',
description: 'List inactive workspaces without removing them',
})
parseDryRun(val: string): boolean {
return Boolean(val);
}
// We look for public tables which contain workspaceId and updatedAt columns and exist in production database
getRelevantTables() {
return Object.keys(this.prismaService.client).filter(
(name) =>
!name.startsWith('_') &&
!name.startsWith('$') &&
!name.includes('user') &&
!name.includes('refreshToken') &&
!name.includes('workspace') &&
!name.includes('favorite'),
);
}
async getMaxUpdatedAtForAllWorkspaces(tables, workspaces) {
const result = {};
for (const table of tables) {
result[table] = {};
const groupByWorkspaces = await this.prismaService.client[table].groupBy({
by: ['workspaceId'],
_max: { updatedAt: true },
where: {
workspaceId: { in: workspaces.map((workspace) => workspace.id) },
},
});
for (const groupByWorkspace of groupByWorkspaces) {
result[table][groupByWorkspace.workspaceId] =
groupByWorkspace._max.updatedAt;
}
}
return result;
}
async addMaxUpdatedAtToWorkspaces(
result,
workspace,
table,
maxUpdatedAtForAllWorkspaces,
) {
const newUpdatedAt = maxUpdatedAtForAllWorkspaces[table][workspace.id];
if (!result[workspace.id]) {
result[workspace.id] = {
displayName: workspace.displayName,
maxUpdatedAt: null,
};
}
if (
newUpdatedAt &&
new Date(result[workspace.id].maxUpdatedAt) < new Date(newUpdatedAt)
) {
result[workspace.id].maxUpdatedAt = newUpdatedAt;
}
}
async getSeedTableData(workspaces) {
const where = {
workspaceId: { in: workspaces.map((workspace) => workspace.id) },
};
const companies = await this.prismaService.client.company.findMany({
select: {
name: true,
domainName: true,
address: true,
employees: true,
workspaceId: true,
},
where,
});
const people = await this.prismaService.client.person.findMany({
select: {
firstName: true,
lastName: true,
city: true,
email: true,
avatarUrl: true,
workspaceId: true,
},
where,
});
const pipelineStages =
await this.prismaService.client.pipelineStage.findMany({
select: {
name: true,
color: true,
type: true,
workspaceId: true,
},
where,
});
const pipelines = await this.prismaService.client.pipeline.findMany({
select: {
name: true,
icon: true,
pipelineProgressableType: true,
workspaceId: true,
},
where,
});
return {
companies,
people,
pipelineStages,
pipelines,
};
}
async detectWorkspacesWithSeedDataOnly(result, workspace, seedTableData) {
const companies = seedTableData.companies.reduce((filtered, company) => {
if (company.workspaceId === workspace.id) {
delete company.workspaceId;
filtered.push(company);
}
return filtered;
}, []);
const people = seedTableData.people.reduce((filtered, person) => {
if (person.workspaceId === workspace.id) {
delete person.workspaceId;
filtered.push(person);
}
return filtered;
}, []);
const pipelineStages = seedTableData.pipelineStages.reduce(
(filtered, pipelineStage) => {
if (pipelineStage.workspaceId === workspace.id) {
delete pipelineStage.workspaceId;
filtered.push(pipelineStage);
}
return filtered;
},
[],
);
const pipelines = seedTableData.pipelines.reduce((filtered, pipeline) => {
if (pipeline.workspaceId === workspace.id) {
delete pipeline.workspaceId;
filtered.push(pipeline);
}
return filtered;
}, []);
if (
isEqual(people, peopleSeed) &&
isEqual(companies, companiesSeed) &&
isEqual(pipelineStages, formattedPipelineStagesSeed) &&
isEqual(pipelines, [pipelinesSeed])
) {
result[workspace.id].sameAsSeed = true;
} else {
{
result[workspace.id].sameAsSeed = false;
}
}
}
async getWorkspaces(options) {
const where = options.workspaceId
? { id: { equals: options.workspaceId } }
: {};
return await this.prismaService.client.workspace.findMany({
where,
orderBy: [{ createdAt: 'asc' }],
});
}
async findInactiveWorkspaces(workspaces, result) {
const tables = this.getRelevantTables();
const maxUpdatedAtForAllWorkspaces =
await this.getMaxUpdatedAtForAllWorkspaces(tables, workspaces);
const seedTableData = await this.getSeedTableData(workspaces);
for (const workspace of workspaces) {
for (const table of tables) {
await this.addMaxUpdatedAtToWorkspaces(
result,
workspace,
table,
maxUpdatedAtForAllWorkspaces,
);
}
await this.detectWorkspacesWithSeedDataOnly(
result,
workspace,
seedTableData,
);
}
}
filterResults(result, options) {
for (const workspaceId in result) {
const timeDifferenceInSeconds = Math.abs(
new Date().getTime() -
new Date(result[workspaceId].maxUpdatedAt).getTime(),
);
const timeDifferenceInDays = Math.ceil(
timeDifferenceInSeconds / (1000 * 3600 * 24),
);
if (
timeDifferenceInDays < options.days &&
(!result[workspaceId].sameAsSeed ||
timeDifferenceInDays < options.sameAsSeedDays)
) {
delete result[workspaceId];
} else {
result[workspaceId].inactiveDays = timeDifferenceInDays;
}
}
}
async delete(result, options) {
const workspaceCount = Object.keys(result).length;
if (workspaceCount) {
console.log(
`Deleting \x1b[36m${workspaceCount}\x1b[0m inactive since \x1b[36m${options.days} days\x1b[0m or same as seed since \x1b[36m${options.sameAsSeedDays} days\x1b[0m workspaces`,
);
}
let count = 1;
for (const workspaceId in result) {
process.stdout.write(`- deleting ${workspaceId} ...`);
await this.workspaceService.deleteWorkspace({
workspaceId,
});
console.log(
` done! ....... ${Math.floor((100 * count) / workspaceCount)}%`,
);
count += 1;
}
}
displayResults(result, totalWorkspacesCount) {
console.log(result);
console.log(
`${
Object.keys(result).length
} out of ${totalWorkspacesCount} workspace(s) checked (${Math.floor(
(100 * Object.keys(result).length) / totalWorkspacesCount,
)}%) will be deleted`,
);
}
async run(
_passedParam: string[],
options: DataCleanInactiveOptions,
): Promise<void> {
const result: DataCleanResults = {};
const workspaces = await this.getWorkspaces(options);
const totalWorkspacesCount = workspaces.length;
console.log(totalWorkspacesCount, 'workspace(s) to analyse');
await this.findInactiveWorkspaces(workspaces, result);
this.filterResults(result, options);
this.displayResults(result, totalWorkspacesCount);
if (!options.dryRun) {
options = await this.inquiererService.ask('confirm', options);
if (!options.confirmation) {
console.log('Cleaning aborted');
return;
}
}
if (!options.dryRun) {
await this.delete(result, options);
}
}
}

View File

@ -1,4 +1,5 @@
import { Command, CommandRunner } from 'nest-commander';
import { DataSource } from 'typeorm';
import { DataSourceService } from 'src/metadata/data-source/data-source.service';
import { WorkspaceMigrationService } from 'src/metadata/workspace-migration/workspace-migration.service';
@ -12,6 +13,8 @@ import { seedOpportunity } from 'src/database/typeorm-seeds/workspace/opportunit
import { seedPipelineStep } from 'src/database/typeorm-seeds/workspace/pipeline-step';
import { seedWorkspaceMember } from 'src/database/typeorm-seeds/workspace/workspaceMember';
import { seedPeople } from 'src/database/typeorm-seeds/workspace/people';
import { seedCoreSchema } from 'src/database/typeorm-seeds/core';
import { EnvironmentService } from 'src/integrations/environment/environment.service';
// TODO: implement dry-run
@Command({
@ -23,6 +26,7 @@ export class DataSeedWorkspaceCommand extends CommandRunner {
workspaceId = '20202020-1c25-4d02-bf25-6aeccf7ea419';
constructor(
private readonly environmentService: EnvironmentService,
private readonly dataSourceService: DataSourceService,
private readonly typeORMService: TypeORMService,
private readonly workspaceMigrationService: WorkspaceMigrationService,
@ -32,6 +36,22 @@ export class DataSeedWorkspaceCommand extends CommandRunner {
}
async run(): Promise<void> {
try {
const dataSource = new DataSource({
url: this.environmentService.getPGDatabaseUrl(),
type: 'postgres',
logging: true,
schema: 'public',
});
await dataSource.initialize();
await seedCoreSchema(dataSource);
await seedMetadataSchema(dataSource);
} catch (error) {
console.error(error);
return;
}
const dataSourceMetadata =
await this.dataSourceService.getLastDataSourceMetadataFromWorkspaceIdOrFail(
this.workspaceId,
@ -46,8 +66,6 @@ export class DataSeedWorkspaceCommand extends CommandRunner {
}
try {
await seedMetadataSchema(workspaceDataSource, 'metadata');
await this.workspaceMigrationService.insertStandardMigrations(
this.workspaceId,
);

View File

@ -1,11 +1,6 @@
import { Module } from '@nestjs/common';
import { DataCleanInactiveCommand } from 'src/database/commands/clean-inactive-workspaces.command';
import { ConfirmationQuestion } from 'src/database/commands/questions/confirmation.question';
import { PipelineModule } from 'src/core/pipeline/pipeline.module';
import { CompanyModule } from 'src/core/company/company.module';
import { PersonModule } from 'src/core/person/person.module';
import { PrismaModule } from 'src/database/prisma.module';
import { WorkspaceManagerModule } from 'src/workspace/workspace-manager/workspace-manager.module';
import { DataSourceModule } from 'src/metadata/data-source/data-source.module';
import { WorkspaceMigrationModule } from 'src/metadata/workspace-migration/workspace-migration.module';
@ -16,21 +11,13 @@ import { DataSeedWorkspaceCommand } from 'src/database/commands/data-seed-worksp
@Module({
imports: [
PipelineModule,
CompanyModule,
PersonModule,
WorkspaceManagerModule,
PrismaModule,
DataSourceModule,
TypeORMModule,
WorkspaceMigrationModule,
WorkspaceMigrationRunnerModule,
WorkspaceModule,
],
providers: [
DataSeedWorkspaceCommand,
DataCleanInactiveCommand,
ConfirmationQuestion,
],
providers: [DataSeedWorkspaceCommand, ConfirmationQuestion],
})
export class DatabaseCommandModule {}

View File

@ -1,103 +0,0 @@
-- CreateTable
CREATE TABLE "users" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"deletedAt" TIMESTAMP(3),
"lastSeen" TIMESTAMP(3),
"disabled" BOOLEAN NOT NULL DEFAULT false,
"displayName" TEXT NOT NULL,
"email" TEXT NOT NULL,
"avatarUrl" TEXT,
"locale" TEXT NOT NULL,
"phoneNumber" TEXT,
"passwordHash" TEXT,
"emailVerified" BOOLEAN NOT NULL DEFAULT false,
"metadata" JSONB,
CONSTRAINT "users_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "workspaces" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"deletedAt" TIMESTAMP(3),
"domainName" TEXT NOT NULL,
"displayName" TEXT NOT NULL,
CONSTRAINT "workspaces_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "workspace_members" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"deletedAt" TIMESTAMP(3),
"userId" TEXT NOT NULL,
"workspaceId" TEXT NOT NULL,
CONSTRAINT "workspace_members_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "companies" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"deletedAt" TIMESTAMP(3),
"name" TEXT NOT NULL,
"domainName" TEXT NOT NULL,
"address" TEXT NOT NULL,
"employees" INTEGER NOT NULL,
"accountOwnerId" TEXT NOT NULL,
"workspaceId" TEXT NOT NULL,
CONSTRAINT "companies_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "people" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"deletedAt" TIMESTAMP(3),
"firstname" TEXT NOT NULL,
"lastname" TEXT NOT NULL,
"email" TEXT NOT NULL,
"phone" TEXT NOT NULL,
"city" TEXT NOT NULL,
"companyId" TEXT NOT NULL,
"workspaceId" TEXT NOT NULL,
CONSTRAINT "people_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "users_email_key" ON "users"("email");
-- CreateIndex
CREATE UNIQUE INDEX "workspaces_domainName_key" ON "workspaces"("domainName");
-- CreateIndex
CREATE UNIQUE INDEX "workspace_members_userId_key" ON "workspace_members"("userId");
-- AddForeignKey
ALTER TABLE "workspace_members" ADD CONSTRAINT "workspace_members_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "workspace_members" ADD CONSTRAINT "workspace_members_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "companies" ADD CONSTRAINT "companies_accountOwnerId_fkey" FOREIGN KEY ("accountOwnerId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "companies" ADD CONSTRAINT "companies_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "people" ADD CONSTRAINT "people_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "companies"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "people" ADD CONSTRAINT "people_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -1,17 +0,0 @@
-- DropForeignKey
ALTER TABLE "companies" DROP CONSTRAINT "companies_accountOwnerId_fkey";
-- DropForeignKey
ALTER TABLE "people" DROP CONSTRAINT "people_companyId_fkey";
-- AlterTable
ALTER TABLE "companies" ALTER COLUMN "accountOwnerId" DROP NOT NULL;
-- AlterTable
ALTER TABLE "people" ALTER COLUMN "companyId" DROP NOT NULL;
-- AddForeignKey
ALTER TABLE "companies" ADD CONSTRAINT "companies_accountOwnerId_fkey" FOREIGN KEY ("accountOwnerId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "people" ADD CONSTRAINT "people_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "companies"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View File

@ -1,2 +0,0 @@
-- AlterTable
ALTER TABLE "companies" ALTER COLUMN "employees" DROP NOT NULL;

View File

@ -1,14 +0,0 @@
-- CreateTable
CREATE TABLE "RefreshToken" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"deletedAt" TIMESTAMP(3),
"refreshToken" TEXT NOT NULL,
"userId" TEXT NOT NULL,
CONSTRAINT "RefreshToken_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "RefreshToken" ADD CONSTRAINT "RefreshToken_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -1,26 +0,0 @@
/*
Warnings:
- You are about to drop the `RefreshToken` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "RefreshToken" DROP CONSTRAINT "RefreshToken_userId_fkey";
-- DropTable
DROP TABLE "RefreshToken";
-- CreateTable
CREATE TABLE "refresh_tokens" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"deletedAt" TIMESTAMP(3),
"refreshToken" TEXT NOT NULL,
"userId" TEXT NOT NULL,
CONSTRAINT "refresh_tokens_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "refresh_tokens" ADD CONSTRAINT "refresh_tokens_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -1,2 +0,0 @@
-- AlterTable
ALTER TABLE "workspaces" ADD COLUMN "logo" TEXT;

View File

@ -1,55 +0,0 @@
-- CreateEnum
CREATE TYPE "CommentableType" AS ENUM ('Person', 'Company');
-- CreateTable
CREATE TABLE "comment_threads" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"deletedAt" TIMESTAMP(3),
"workspaceId" TEXT NOT NULL,
CONSTRAINT "comment_threads_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "comments" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"deletedAt" TIMESTAMP(3),
"body" TEXT NOT NULL,
"authorId" TEXT NOT NULL,
"commentThreadId" TEXT NOT NULL,
"workspaceId" TEXT NOT NULL,
CONSTRAINT "comments_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "comment_thread_targets" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"deletedAt" TIMESTAMP(3),
"commentThreadId" TEXT NOT NULL,
"commentableType" "CommentableType" NOT NULL,
"commentableId" TEXT NOT NULL,
CONSTRAINT "comment_thread_targets_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "comment_threads" ADD CONSTRAINT "comment_threads_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "comments" ADD CONSTRAINT "comments_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "comments" ADD CONSTRAINT "comments_commentThreadId_fkey" FOREIGN KEY ("commentThreadId") REFERENCES "comment_threads"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "comments" ADD CONSTRAINT "comments_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "comment_thread_targets" ADD CONSTRAINT "comment_thread_targets_commentThreadId_fkey" FOREIGN KEY ("commentThreadId") REFERENCES "comment_threads"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -1,59 +0,0 @@
-- CreateEnum
CREATE TYPE "PipelineProgressableType" AS ENUM ('Person', 'Company');
-- CreateTable
CREATE TABLE "pipelines" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"deletedAt" TIMESTAMP(3),
"name" TEXT NOT NULL,
"icon" TEXT NOT NULL,
"workspaceId" TEXT NOT NULL,
CONSTRAINT "pipelines_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "pipeline_stages" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"deletedAt" TIMESTAMP(3),
"name" TEXT NOT NULL,
"type" TEXT NOT NULL,
"color" TEXT NOT NULL,
"pipelineId" TEXT NOT NULL,
"workspaceId" TEXT NOT NULL,
CONSTRAINT "pipeline_stages_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "pipeline_progresses" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"deletedAt" TIMESTAMP(3),
"pipelineId" TEXT NOT NULL,
"pipelineStageId" TEXT NOT NULL,
"associableType" "PipelineProgressableType" NOT NULL,
"associableId" TEXT NOT NULL,
CONSTRAINT "pipeline_progresses_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "pipelines" ADD CONSTRAINT "pipelines_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "pipeline_stages" ADD CONSTRAINT "pipeline_stages_pipelineId_fkey" FOREIGN KEY ("pipelineId") REFERENCES "pipelines"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "pipeline_stages" ADD CONSTRAINT "pipeline_stages_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "pipeline_progresses" ADD CONSTRAINT "pipeline_progresses_pipelineId_fkey" FOREIGN KEY ("pipelineId") REFERENCES "pipelines"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "pipeline_progresses" ADD CONSTRAINT "pipeline_progresses_pipelineStageId_fkey" FOREIGN KEY ("pipelineStageId") REFERENCES "pipeline_stages"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -1,13 +0,0 @@
/*
Warnings:
- You are about to drop the column `associableId` on the `pipeline_progresses` table. All the data in the column will be lost.
- You are about to drop the column `associableType` on the `pipeline_progresses` table. All the data in the column will be lost.
- Added the required column `progressableId` to the `pipeline_progresses` table without a default value. This is not possible if the table is not empty.
- Added the required column `progressableType` to the `pipeline_progresses` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "pipeline_progresses" RENAME "associableId" TO "progressableId";
ALTER TABLE "pipeline_progresses" RENAME "associableType" TO "progressableType";

View File

@ -1,11 +0,0 @@
/*
Warnings:
- Added the required column `workspaceId` to the `pipeline_progresses` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "pipeline_progresses" ADD COLUMN "workspaceId" TEXT NOT NULL;
-- AddForeignKey
ALTER TABLE "pipeline_progresses" ADD CONSTRAINT "pipeline_progresses_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -1,11 +0,0 @@
/*
Warnings:
- You are about to drop the column `refreshToken` on the `refresh_tokens` table. All the data in the column will be lost.
- Added the required column `expiresAt` to the `refresh_tokens` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "refresh_tokens" DROP COLUMN "refreshToken",
ADD COLUMN "expiresAt" TIMESTAMP(3) NOT NULL,
ADD COLUMN "isRevoked" BOOLEAN NOT NULL DEFAULT false;

View File

@ -1,2 +0,0 @@
-- AlterTable
ALTER TABLE "pipelines" ADD COLUMN "pipelineProgressableType" "PipelineProgressableType" NOT NULL DEFAULT 'Company';

View File

@ -1,5 +0,0 @@
-- DropForeignKey
ALTER TABLE "comments" DROP CONSTRAINT "comments_commentThreadId_fkey";
-- AddForeignKey
ALTER TABLE "comments" ADD CONSTRAINT "comments_commentThreadId_fkey" FOREIGN KEY ("commentThreadId") REFERENCES "comment_threads"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -1,5 +0,0 @@
-- DropForeignKey
ALTER TABLE "comment_thread_targets" DROP CONSTRAINT "comment_thread_targets_commentThreadId_fkey";
-- AddForeignKey
ALTER TABLE "comment_thread_targets" ADD CONSTRAINT "comment_thread_targets_commentThreadId_fkey" FOREIGN KEY ("commentThreadId") REFERENCES "comment_threads"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -1,11 +0,0 @@
/*
Warnings:
- Added the required column `firstName` to the `users` table without a default value. This is not possible if the table is not empty.
- Added the required column `lastName` to the `users` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "users" ADD COLUMN "firstName" TEXT NOT NULL DEFAULT '',
ADD COLUMN "lastName" TEXT NOT NULL DEFAULT '',
ALTER COLUMN "displayName" DROP NOT NULL;

View File

@ -1,19 +0,0 @@
-- AlterTable
ALTER TABLE "people"
ADD COLUMN "firstName" TEXT,
ADD COLUMN "lastName" TEXT;
-- Update new columns using old columns
UPDATE "people"
SET "firstName" = "firstname",
"lastName" = "lastname";
-- Drop old columns
ALTER TABLE "people"
DROP COLUMN "firstname",
DROP COLUMN "lastname";
-- Make new columns NOT NULL
ALTER TABLE "people"
ALTER COLUMN "firstName" SET NOT NULL,
ALTER COLUMN "lastName" SET NOT NULL;

View File

@ -1,10 +0,0 @@
/*
Warnings:
- You are about to drop the column `displayName` on the `users` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "users" DROP COLUMN "displayName",
ALTER COLUMN "firstName" DROP DEFAULT,
ALTER COLUMN "lastName" DROP DEFAULT;

View File

@ -1,15 +0,0 @@
-- AlterTable
ALTER TABLE "comment_threads" ADD COLUMN "body" TEXT,
ADD COLUMN "title" TEXT,
ADD COLUMN "authorId" TEXT;
-- Update field with a random user if some rows already exist...
UPDATE "comment_threads"
SET "authorId" = (SELECT id FROM users LIMIT 1);
ALTER TABLE "comment_threads"
ALTER COLUMN "authorId" SET NOT NULL;
ALTER TABLE "comment_threads" ADD CONSTRAINT "comment_threads_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -1,6 +0,0 @@
-- DropIndex
DROP INDEX "workspaces_domainName_key";
-- AlterTable
ALTER TABLE "workspaces" ALTER COLUMN "domainName" DROP NOT NULL,
ALTER COLUMN "displayName" DROP NOT NULL;

View File

@ -1,3 +0,0 @@
-- AlterTable
ALTER TABLE "users" ALTER COLUMN "firstName" DROP NOT NULL,
ALTER COLUMN "lastName" DROP NOT NULL;

View File

@ -1,3 +0,0 @@
-- AlterTable
ALTER TABLE "pipeline_progresses" ADD COLUMN "amount" INTEGER,
ADD COLUMN "closeDate" TIMESTAMP(3);

View File

@ -1,2 +0,0 @@
-- AlterTable
ALTER TABLE "pipeline_stages" ADD COLUMN "index" INTEGER;

View File

@ -1,2 +0,0 @@
-- AlterTable
ALTER TABLE "workspaces" ADD COLUMN "inviteHash" TEXT;

View File

@ -1,12 +0,0 @@
-- CreateEnum
CREATE TYPE "ActivityType" AS ENUM ('Note', 'Task');
-- AlterTable
ALTER TABLE "comment_threads" ADD COLUMN "assigneeId" TEXT,
ADD COLUMN "completedAt" TIMESTAMP(3),
ADD COLUMN "dueAt" TIMESTAMP(3),
ADD COLUMN "reminderAt" TIMESTAMP(3),
ADD COLUMN "type" "ActivityType" NOT NULL DEFAULT 'Note';
-- AddForeignKey
ALTER TABLE "comment_threads" ADD CONSTRAINT "comment_threads_assigneeId_fkey" FOREIGN KEY ("assigneeId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View File

@ -1,19 +0,0 @@
-- Adding 'settingsId' to 'users' table without NOT NULL constraint initially
ALTER TABLE "users" ADD COLUMN "settingsId" TEXT;
-- Creating 'user_settings' table
CREATE TYPE "ColorScheme" AS ENUM ('Light', 'Dark', 'System');
CREATE TABLE "user_settings" (
"id" TEXT NOT NULL,
"colorScheme" "ColorScheme" NOT NULL DEFAULT 'System',
"locale" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "user_settings_pkey" PRIMARY KEY ("id")
);
-- Applying constraints and indexes
CREATE UNIQUE INDEX "users_settingsId_key" ON "users"("settingsId");
ALTER TABLE "users" ADD CONSTRAINT "users_settingsId_fkey" FOREIGN KEY ("settingsId") REFERENCES "user_settings"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -1,24 +0,0 @@
-- CreateEnum
CREATE TYPE "AttachmentType" AS ENUM ('Image', 'Audio', 'Video', 'TextDocument', 'Spreadsheet', 'Archive', 'Other');
-- CreateTable
CREATE TABLE "attachments" (
"id" TEXT NOT NULL,
"fullPath" TEXT NOT NULL,
"type" "AttachmentType" NOT NULL,
"name" TEXT NOT NULL,
"authorId" TEXT NOT NULL,
"activityId" TEXT NOT NULL,
"workspaceId" TEXT NOT NULL,
"deletedAt" TIMESTAMP(3),
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "attachments_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "attachments" ADD CONSTRAINT "attachments_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "attachments" ADD CONSTRAINT "attachments_activityId_fkey" FOREIGN KEY ("activityId") REFERENCES "comment_threads"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -1,15 +0,0 @@
/*
Warnings:
- Made the column `settingsId` on table `users` required. This step will fail if there are existing NULL values in that column.
*/
-- AlterTable
ALTER TABLE "pipeline_progresses" ADD COLUMN "pointOfContactId" TEXT,
ADD COLUMN "probability" INTEGER;
-- AlterTable
ALTER TABLE "users" ALTER COLUMN "settingsId" SET NOT NULL;
-- AddForeignKey
ALTER TABLE "pipeline_progresses" ADD CONSTRAINT "pipeline_progresses_pointOfContactId_fkey" FOREIGN KEY ("pointOfContactId") REFERENCES "people"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View File

@ -1,6 +0,0 @@
-- AlterTable
ALTER TABLE "people" ALTER COLUMN "email" DROP NOT NULL,
ALTER COLUMN "phone" DROP NOT NULL,
ALTER COLUMN "city" DROP NOT NULL,
ALTER COLUMN "firstName" DROP NOT NULL,
ALTER COLUMN "lastName" DROP NOT NULL;

View File

@ -1,14 +0,0 @@
/*
Warnings:
- Added the required column `workspaceId` to the `comment_thread_targets` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "comment_thread_targets" ADD COLUMN "workspaceId" TEXT;
-- AddForeignKey
ALTER TABLE "comment_thread_targets" ADD CONSTRAINT "comment_thread_targets_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "attachments" ADD CONSTRAINT "attachments_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -1,6 +0,0 @@
-- AlterTable
ALTER TABLE "companies" ADD COLUMN "linkedinUrl" TEXT;
-- AlterTable
ALTER TABLE "people" ADD COLUMN "jobTitle" TEXT,
ADD COLUMN "linkedinUrl" TEXT;

View File

@ -1,32 +0,0 @@
-- Activities Table
CREATE TABLE "activities" (
"id" TEXT NOT NULL,
"body" TEXT,
"title" TEXT,
"type" "ActivityType" NOT NULL DEFAULT 'Note',
"reminderAt" TIMESTAMP(3),
"dueAt" TIMESTAMP(3),
"completedAt" TIMESTAMP(3),
"authorId" TEXT NOT NULL,
"assigneeId" TEXT,
"workspaceId" TEXT NOT NULL,
"deletedAt" TIMESTAMP(3),
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "activities_pkey" PRIMARY KEY ("id")
);
-- Activity Targets Table
CREATE TABLE "activity_targets" (
"id" TEXT NOT NULL,
"activityId" TEXT NOT NULL,
"personId" TEXT NOT NULL,
"companyId" TEXT NOT NULL,
"workspaceId" TEXT NOT NULL,
"deletedAt" TIMESTAMP(3),
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "activity_targets_pkey" PRIMARY KEY ("id")
);

View File

@ -1,15 +0,0 @@
-- CreateTable
CREATE TABLE "viewFields" (
"id" TEXT NOT NULL,
"fieldName" TEXT NOT NULL,
"index" INTEGER NOT NULL,
"isVisible" BOOLEAN NOT NULL,
"objectName" TEXT NOT NULL,
"sizeInPx" INTEGER NOT NULL,
"workspaceId" TEXT NOT NULL,
CONSTRAINT "viewFields_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "viewFields" ADD CONSTRAINT "viewFields_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -1,69 +0,0 @@
/*
Warnings:
- You are about to drop the `comment_thread_targets` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `comment_threads` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "attachments" DROP CONSTRAINT "attachments_activityId_fkey";
-- DropForeignKey
ALTER TABLE "comment_thread_targets" DROP CONSTRAINT "comment_thread_targets_commentThreadId_fkey";
-- DropForeignKey
ALTER TABLE "comment_thread_targets" DROP CONSTRAINT "comment_thread_targets_workspaceId_fkey";
-- DropForeignKey
ALTER TABLE "comment_threads" DROP CONSTRAINT "comment_threads_assigneeId_fkey";
-- DropForeignKey
ALTER TABLE "comment_threads" DROP CONSTRAINT "comment_threads_authorId_fkey";
-- DropForeignKey
ALTER TABLE "comment_threads" DROP CONSTRAINT "comment_threads_workspaceId_fkey";
-- DropForeignKey
ALTER TABLE "comments" DROP CONSTRAINT "comments_commentThreadId_fkey";
-- AlterTable
ALTER TABLE "activity_targets" ADD COLUMN "commentableId" TEXT,
ADD COLUMN "commentableType" "CommentableType",
ALTER COLUMN "personId" DROP NOT NULL,
ALTER COLUMN "companyId" DROP NOT NULL;
-- AlterTable
ALTER TABLE "comments" ADD COLUMN "activityId" TEXT;
-- DropTable
DROP TABLE "comment_thread_targets";
-- DropTable
DROP TABLE "comment_threads";
-- AddForeignKey
ALTER TABLE "activities" ADD CONSTRAINT "activities_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "activities" ADD CONSTRAINT "activities_assigneeId_fkey" FOREIGN KEY ("assigneeId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "activities" ADD CONSTRAINT "activities_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "comments" ADD CONSTRAINT "comments_activityId_fkey" FOREIGN KEY ("activityId") REFERENCES "activities"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "activity_targets" ADD CONSTRAINT "activity_targets_activityId_fkey" FOREIGN KEY ("activityId") REFERENCES "activities"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "activity_targets" ADD CONSTRAINT "activity_targets_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "activity_targets" ADD CONSTRAINT "activity_targets_personId_fkey" FOREIGN KEY ("personId") REFERENCES "people"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "activity_targets" ADD CONSTRAINT "activity_targets_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "companies"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "attachments" ADD CONSTRAINT "attachments_activityId_fkey" FOREIGN KEY ("activityId") REFERENCES "activities"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -1,2 +0,0 @@
-- AlterTable
ALTER TABLE "comments" ALTER COLUMN "commentThreadId" DROP NOT NULL;

View File

@ -1,2 +0,0 @@
-- AlterTable
ALTER TABLE "people" ADD COLUMN "avatarUrl" TEXT;

View File

@ -1,5 +0,0 @@
-- AlterTable
ALTER TABLE "users" ADD COLUMN "canImpersonate" BOOLEAN NOT NULL DEFAULT false;
-- AlterTable
ALTER TABLE "workspace_members" ADD COLUMN "allowImpersonation" BOOLEAN NOT NULL DEFAULT true;

View File

@ -1,9 +0,0 @@
-- AlterTable
ALTER TABLE "pipeline_progresses" ADD COLUMN "companyId" TEXT,
ADD COLUMN "personId" TEXT;
-- AddForeignKey
--ALTER TABLE "pipeline_progresses" ADD CONSTRAINT "pipeline_progresses_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "companies"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
--ALTER TABLE "pipeline_progresses" ADD CONSTRAINT "pipeline_progresses_personId_fkey" FOREIGN KEY ("personId") REFERENCES "people"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View File

@ -1,8 +0,0 @@
-- This is a manually written data migration that copies the progressable ids to the right colums in pipeline progress.
UPDATE "pipeline_progresses" SET
"companyId"="progressableId"
WHERE "progressableType"='Company';
UPDATE "pipeline_progresses" SET
"personId"="progressableId"
WHERE "progressableType"='Person';

View File

@ -1,8 +0,0 @@
/*
Warnings:
- You are about to drop the column `progressableId` on the `pipeline_progresses` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "pipeline_progresses" DROP COLUMN "progressableId";

View File

@ -1,8 +0,0 @@
/*
Warnings:
- You are about to drop the column `progressableType` on the `pipeline_progresses` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "pipeline_progresses" DROP COLUMN "progressableType";

View File

@ -1,2 +0,0 @@
-- AlterTable
ALTER TABLE "people" ADD COLUMN "twitterUrl" TEXT;

View File

@ -1,2 +0,0 @@
-- AlterTable
ALTER TABLE "people" RENAME COLUMN "twitterUrl" TO "xUrl";

View File

@ -1,34 +0,0 @@
/*
Warnings:
- A unique constraint covering the columns `[workspaceId,viewId,objectName,fieldName]` on the table `viewFields` will be added. If there are existing duplicate values, this will fail.
*/
-- CreateEnum
CREATE TYPE "ViewType" AS ENUM ('Table', 'Pipeline');
-- AlterTable
ALTER TABLE "viewFields" ADD COLUMN "viewId" TEXT;
-- CreateTable
CREATE TABLE "views" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"objectId" TEXT NOT NULL,
"type" "ViewType" NOT NULL,
"workspaceId" TEXT NOT NULL,
CONSTRAINT "views_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "views_workspaceId_type_objectId_name_key" ON "views"("workspaceId", "type", "objectId", "name");
-- CreateIndex
CREATE UNIQUE INDEX "viewFields_workspaceId_viewId_objectName_fieldName_key" ON "viewFields"("workspaceId", "viewId", "objectName", "fieldName");
-- AddForeignKey
ALTER TABLE "views" ADD CONSTRAINT "views_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "viewFields" ADD CONSTRAINT "viewFields_viewId_fkey" FOREIGN KEY ("viewId") REFERENCES "views"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View File

@ -1,19 +0,0 @@
-- CreateEnum
CREATE TYPE "ViewSortDirection" AS ENUM ('asc', 'desc');
-- CreateTable
CREATE TABLE "viewSorts" (
"direction" "ViewSortDirection" NOT NULL,
"key" TEXT NOT NULL,
"name" TEXT NOT NULL,
"viewId" TEXT NOT NULL,
"workspaceId" TEXT NOT NULL,
CONSTRAINT "viewSorts_pkey" PRIMARY KEY ("viewId","key")
);
-- AddForeignKey
ALTER TABLE "viewSorts" ADD CONSTRAINT "viewSorts_viewId_fkey" FOREIGN KEY ("viewId") REFERENCES "views"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "viewSorts" ADD CONSTRAINT "viewSorts_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -1,19 +0,0 @@
-- CreateTable
CREATE TABLE "favorites" (
"id" TEXT NOT NULL,
"workspaceId" TEXT,
"personId" TEXT,
"companyId" TEXT,
"workspaceMemberId" TEXT,
CONSTRAINT "favorites_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "favorites" ADD CONSTRAINT "favorites_personId_fkey" FOREIGN KEY ("personId") REFERENCES "people"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "favorites" ADD CONSTRAINT "favorites_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "companies"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "favorites" ADD CONSTRAINT "favorites_workspaceMemberId_fkey" FOREIGN KEY ("workspaceMemberId") REFERENCES "workspace_members"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View File

@ -1,17 +0,0 @@
-- DropForeignKey
ALTER TABLE "activity_targets" DROP CONSTRAINT "activity_targets_companyId_fkey";
-- DropForeignKey
ALTER TABLE "activity_targets" DROP CONSTRAINT "activity_targets_personId_fkey";
-- AddForeignKey
ALTER TABLE "activity_targets" ADD CONSTRAINT "activity_targets_personId_fkey" FOREIGN KEY ("personId") REFERENCES "people"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "activity_targets" ADD CONSTRAINT "activity_targets_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "companies"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "pipeline_progresses" ADD CONSTRAINT "pipeline_progresses_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "companies"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "pipeline_progresses" ADD CONSTRAINT "pipeline_progresses_personId_fkey" FOREIGN KEY ("personId") REFERENCES "people"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -1,13 +0,0 @@
/*
Warnings:
- You are about to drop the column `commentableId` on the `activity_targets` table. All the data in the column will be lost.
- You are about to drop the column `commentableType` on the `activity_targets` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "activity_targets" DROP COLUMN "commentableId",
DROP COLUMN "commentableType";
-- DropEnum
DROP TYPE "CommentableType";

View File

@ -1,53 +0,0 @@
-- DropForeignKey
ALTER TABLE "activities" DROP CONSTRAINT "activities_authorId_fkey";
-- DropForeignKey
ALTER TABLE "attachments" DROP CONSTRAINT "attachments_activityId_fkey";
-- DropForeignKey
ALTER TABLE "attachments" DROP CONSTRAINT "attachments_authorId_fkey";
-- DropForeignKey
ALTER TABLE "favorites" DROP CONSTRAINT "favorites_companyId_fkey";
-- DropForeignKey
ALTER TABLE "favorites" DROP CONSTRAINT "favorites_personId_fkey";
-- DropForeignKey
ALTER TABLE "pipeline_progresses" DROP CONSTRAINT "pipeline_progresses_pipelineId_fkey";
-- DropForeignKey
ALTER TABLE "pipeline_progresses" DROP CONSTRAINT "pipeline_progresses_pipelineStageId_fkey";
-- DropForeignKey
ALTER TABLE "pipeline_stages" DROP CONSTRAINT "pipeline_stages_pipelineId_fkey";
-- DropForeignKey
ALTER TABLE "comments" DROP CONSTRAINT "comments_authorId_fkey";
-- AddForeignKey
ALTER TABLE "activities" ADD CONSTRAINT "activities_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "pipeline_stages" ADD CONSTRAINT "pipeline_stages_pipelineId_fkey" FOREIGN KEY ("pipelineId") REFERENCES "pipelines"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "pipeline_progresses" ADD CONSTRAINT "pipeline_progresses_pipelineId_fkey" FOREIGN KEY ("pipelineId") REFERENCES "pipelines"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "pipeline_progresses" ADD CONSTRAINT "pipeline_progresses_pipelineStageId_fkey" FOREIGN KEY ("pipelineStageId") REFERENCES "pipeline_stages"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "attachments" ADD CONSTRAINT "attachments_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "attachments" ADD CONSTRAINT "attachments_activityId_fkey" FOREIGN KEY ("activityId") REFERENCES "activities"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "favorites" ADD CONSTRAINT "favorites_personId_fkey" FOREIGN KEY ("personId") REFERENCES "people"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "favorites" ADD CONSTRAINT "favorites_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "companies"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "comments" ADD CONSTRAINT "comments_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -1,11 +0,0 @@
-- DropForeignKey
ALTER TABLE "viewFields" DROP CONSTRAINT "viewFields_viewId_fkey";
-- DropForeignKey
ALTER TABLE "viewSorts" DROP CONSTRAINT "viewSorts_viewId_fkey";
-- AddForeignKey
ALTER TABLE "viewSorts" ADD CONSTRAINT "viewSorts_viewId_fkey" FOREIGN KEY ("viewId") REFERENCES "views"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "viewFields" ADD CONSTRAINT "viewFields_viewId_fkey" FOREIGN KEY ("viewId") REFERENCES "views"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -1,4 +0,0 @@
-- AlterTable
ALTER TABLE "companies" ADD COLUMN "annualRecurringRevenue" INTEGER,
ADD COLUMN "idealCustomerProfile" BOOLEAN DEFAULT false,
ADD COLUMN "xUrl" TEXT;

View File

@ -1,21 +0,0 @@
-- CreateEnum
CREATE TYPE "ViewFilterOperand" AS ENUM ('Contains', 'DoesNotContain', 'GreaterThan', 'LessThan', 'Is', 'IsNot');
-- CreateTable
CREATE TABLE "viewFilters" (
"displayValue" TEXT NOT NULL,
"key" TEXT NOT NULL,
"name" TEXT NOT NULL,
"operand" "ViewFilterOperand" NOT NULL,
"value" TEXT NOT NULL,
"viewId" TEXT NOT NULL,
"workspaceId" TEXT NOT NULL,
CONSTRAINT "viewFilters_pkey" PRIMARY KEY ("viewId","key")
);
-- AddForeignKey
ALTER TABLE "viewFilters" ADD CONSTRAINT "viewFilters_viewId_fkey" FOREIGN KEY ("viewId") REFERENCES "views"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "viewFilters" ADD CONSTRAINT "viewFilters_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -1,2 +0,0 @@
-- DropIndex
DROP INDEX "views_workspaceId_type_objectId_name_key";

View File

@ -1,18 +0,0 @@
/*
Warnings:
- The primary key for the `viewFields` table will be changed. If it partially fails, the table could be left without primary key constraint.
- You are about to drop the column `id` on the `viewFields` table. All the data in the column will be lost.
- Added the required column `key` to the `viewFields` table without a default value. This is not possible if the table is not empty.
- Made the column `viewId` on table `viewFields` required. This step will fail if there are existing NULL values in that column.
*/
-- DropIndex
DROP INDEX "viewFields_workspaceId_viewId_objectName_fieldName_key";
-- AlterTable
ALTER TABLE "viewFields" DROP CONSTRAINT "viewFields_pkey",
DROP COLUMN "id",
ADD COLUMN "key" TEXT NOT NULL,
ALTER COLUMN "viewId" SET NOT NULL,
ADD CONSTRAINT "viewFields_pkey" PRIMARY KEY ("viewId", "key");

View File

@ -1,4 +0,0 @@
-- AlterTable
ALTER TABLE "viewFields" RENAME COLUMN "fieldName" TO "name";
ALTER TABLE "viewFields" RENAME COLUMN "objectName" TO "objectId";
ALTER TABLE "viewFields" RENAME COLUMN "sizeInPx" TO "size";

View File

@ -1,40 +0,0 @@
/*
Warnings:
- Made the column `idealCustomerProfile` on table `companies` required. This step will fail if there are existing NULL values in that column.
*/
-- AlterTable
ALTER TABLE "activities" ADD COLUMN "workspaceMemberAssigneeId" TEXT,
ADD COLUMN "workspaceMemberAuthorId" TEXT;
-- AlterTable
ALTER TABLE "attachments" ADD COLUMN "workspaceMemberAuthorId" TEXT;
-- AlterTable
ALTER TABLE "comments" ADD COLUMN "workspaceMemberAuthorId" TEXT;
-- AlterTable
ALTER TABLE "companies" ADD COLUMN "workspaceMemberAccountOwnerId" TEXT,
ALTER COLUMN "idealCustomerProfile" SET NOT NULL;
-- AlterTable
ALTER TABLE "workspace_members" ADD COLUMN "settingsId" TEXT;
-- AddForeignKey
ALTER TABLE "workspace_members" ADD CONSTRAINT "workspace_members_settingsId_fkey" FOREIGN KEY ("settingsId") REFERENCES "user_settings"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "companies" ADD CONSTRAINT "companies_workspaceMemberAccountOwnerId_fkey" FOREIGN KEY ("workspaceMemberAccountOwnerId") REFERENCES "workspace_members"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "activities" ADD CONSTRAINT "activities_workspaceMemberAuthorId_fkey" FOREIGN KEY ("workspaceMemberAuthorId") REFERENCES "workspace_members"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "activities" ADD CONSTRAINT "activities_workspaceMemberAssigneeId_fkey" FOREIGN KEY ("workspaceMemberAssigneeId") REFERENCES "workspace_members"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "comments" ADD CONSTRAINT "comments_workspaceMemberAuthorId_fkey" FOREIGN KEY ("workspaceMemberAuthorId") REFERENCES "workspace_members"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "attachments" ADD CONSTRAINT "attachments_workspaceMemberAuthorId_fkey" FOREIGN KEY ("workspaceMemberAuthorId") REFERENCES "workspace_members"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -1,2 +0,0 @@
-- AlterTable
ALTER TABLE "viewFields" ALTER COLUMN "size" DROP NOT NULL;

View File

@ -1,2 +0,0 @@
-- AlterTable
ALTER TABLE "viewFields" ALTER COLUMN "index" SET DATA TYPE DOUBLE PRECISION;

View File

@ -1,5 +0,0 @@
-- CreateEnum
CREATE TYPE "Currency" AS ENUM ('AED', 'AFN', 'ALL', 'AMD', 'ANG', 'AOA', 'ARS', 'AUD', 'AWG', 'AZN', 'BAM', 'BBD', 'BDT', 'BGN', 'BHD', 'BIF', 'BMD', 'BND', 'BOB', 'BOV', 'BRL', 'BSD', 'BTN', 'BWP', 'BYN', 'BZD', 'CAD', 'CDF', 'CHF', 'CLF', 'CLP', 'CNY', 'COP', 'COU', 'CRC', 'CUC', 'CUP', 'CVE', 'CZK', 'DJF', 'DKK', 'DOP', 'DZD', 'EGP', 'ERN', 'ETB', 'EUR', 'FJD', 'FKP', 'GBP', 'GEL', 'GHS', 'GIP', 'GMD', 'GNF', 'GTQ', 'GYD', 'HKD', 'HNL', 'HRK', 'HTG', 'HUF', 'IDR', 'ILS', 'INR', 'IQD', 'IRR', 'ISK', 'JMD', 'JOD', 'JPY', 'KES', 'KGS', 'KHR', 'KMF', 'KPW', 'KRW', 'KWD', 'KYD', 'KZT', 'LAK', 'LBP', 'LKR', 'LRD', 'LSL', 'LYD', 'MAD', 'MDL', 'MGA', 'MKD', 'MMK', 'MNT', 'MOP', 'MRO', 'MRU', 'MUR', 'MVR', 'MWK', 'MXN', 'MXV', 'MYR', 'MZN', 'NAD', 'NGN', 'NIO', 'NOK', 'NPR', 'NZD', 'OMR', 'PAB', 'PEN', 'PGK', 'PHP', 'PKR', 'PLN', 'PYG', 'QAR', 'RON', 'RSD', 'RUB', 'RWF', 'SAR', 'SBD', 'SCR', 'SDD', 'SDG', 'SEK', 'SGD', 'SHP', 'SLL', 'SOS', 'SRD', 'SSP', 'STD', 'STN', 'SVC', 'SYP', 'SZL', 'THB', 'TJS', 'TMM', 'TMT', 'TND', 'TOP', 'TRY', 'TTD', 'TWD', 'TZS', 'UAH', 'UGX', 'USD', 'UYU', 'UZS', 'VEF', 'VES', 'VND', 'VUV', 'WST', 'XAF', 'XCD', 'XOF', 'XPF', 'XSU', 'XUA', 'YER', 'ZAR', 'ZMW', 'ZWL');
-- AlterTable
ALTER TABLE "pipelines" ADD COLUMN "currency" "Currency" NOT NULL DEFAULT 'USD';

View File

@ -1,10 +0,0 @@
-- AlterTable
ALTER TABLE "attachments" ADD COLUMN "companyId" TEXT,
ADD COLUMN "personId" TEXT,
ALTER COLUMN "activityId" DROP NOT NULL;
-- AddForeignKey
ALTER TABLE "attachments" ADD CONSTRAINT "attachments_personId_fkey" FOREIGN KEY ("personId") REFERENCES "people"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "attachments" ADD CONSTRAINT "attachments_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "companies"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -1,8 +0,0 @@
-- Step 1: Add the new column
ALTER TABLE "refresh_tokens" ADD COLUMN "revokedAt" TIMESTAMP(3);
-- Step 2: Update the new column based on the isRevoked column value
UPDATE "refresh_tokens" SET "revokedAt" = NOW() - INTERVAL '1 day' WHERE "isRevoked" = TRUE;
-- Step 3: Drop the isRevoked column
ALTER TABLE "refresh_tokens" DROP COLUMN "isRevoked";

View File

@ -1,22 +0,0 @@
-- AlterEnum
ALTER TYPE "ViewFilterOperand" ADD VALUE 'IsNotNull';
-- CreateTable
CREATE TABLE "api_keys" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"key" TEXT NOT NULL,
"workspaceId" TEXT NOT NULL,
"expiresAt" TIMESTAMP(3),
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"deletedAt" TIMESTAMP(3),
CONSTRAINT "api_keys_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "api_keys_key_key" ON "api_keys"("key");
-- AddForeignKey
ALTER TABLE "api_keys" ADD CONSTRAINT "api_keys_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -1,12 +0,0 @@
/*
Warnings:
- You are about to drop the column `key` on the `api_keys` table. All the data in the column will be lost.
*/
-- DropIndex
DROP INDEX "api_keys_key_key";
-- AlterTable
ALTER TABLE "api_keys" DROP COLUMN "key",
ADD COLUMN "revokedAt" TIMESTAMP(3);

View File

@ -1,15 +0,0 @@
-- CreateTable
CREATE TABLE "hooks" (
"id" TEXT NOT NULL,
"workspaceId" TEXT NOT NULL,
"targetUrl" TEXT NOT NULL,
"operation" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"deletedAt" TIMESTAMP(3),
CONSTRAINT "hooks_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "hooks" ADD CONSTRAINT "hooks_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -1,8 +0,0 @@
/*
Warnings:
- Added the required column `position` to the `favorites` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "favorites" ADD COLUMN "position" DOUBLE PRECISION NOT NULL;

View File

@ -1,27 +0,0 @@
/*
Warnings:
- You are about to drop the `hooks` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "hooks" DROP CONSTRAINT "hooks_workspaceId_fkey";
-- DropTable
DROP TABLE "hooks";
-- CreateTable
CREATE TABLE "web_hooks" (
"id" TEXT NOT NULL,
"workspaceId" TEXT NOT NULL,
"targetUrl" TEXT NOT NULL,
"operation" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"deletedAt" TIMESTAMP(3),
CONSTRAINT "web_hooks_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "web_hooks" ADD CONSTRAINT "web_hooks_workspaceId_fkey" FOREIGN KEY ("workspaceId") REFERENCES "workspaces"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -1,52 +0,0 @@
/*
Warnings:
- You are about to drop the column `index` on the `pipeline_stages` table. All the data in the column will be lost.
- You are about to drop the `viewFields` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `viewFilters` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `viewSorts` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `views` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "viewFields" DROP CONSTRAINT "viewFields_viewId_fkey";
-- DropForeignKey
ALTER TABLE "viewFields" DROP CONSTRAINT "viewFields_workspaceId_fkey";
-- DropForeignKey
ALTER TABLE "viewFilters" DROP CONSTRAINT "viewFilters_viewId_fkey";
-- DropForeignKey
ALTER TABLE "viewFilters" DROP CONSTRAINT "viewFilters_workspaceId_fkey";
-- DropForeignKey
ALTER TABLE "viewSorts" DROP CONSTRAINT "viewSorts_viewId_fkey";
-- DropForeignKey
ALTER TABLE "viewSorts" DROP CONSTRAINT "viewSorts_workspaceId_fkey";
-- DropForeignKey
ALTER TABLE "views" DROP CONSTRAINT "views_workspaceId_fkey";
-- AlterTable
ALTER TABLE "pipeline_stages" DROP COLUMN "index",
ADD COLUMN "position" INTEGER;
-- DropTable
DROP TABLE "viewFields";
-- DropTable
DROP TABLE "viewFilters";
-- DropTable
DROP TABLE "viewSorts";
-- DropTable
DROP TABLE "views";
-- DropEnum
DROP TYPE "ViewFilterOperand";
-- DropEnum
DROP TYPE "ViewSortDirection";

View File

@ -1,5 +0,0 @@
-- DropForeignKey
ALTER TABLE "workspace_members" DROP CONSTRAINT "workspace_members_userId_fkey";
-- AlterTable
ALTER TABLE "users" ADD COLUMN "defaultWorkspaceId" TEXT;

View File

@ -1,20 +0,0 @@
/*
Warnings:
- You are about to drop the column `settingsId` on the `users` table. All the data in the column will be lost.
*/
-- DropForeignKey
ALTER TABLE "users" DROP CONSTRAINT "users_settingsId_fkey";
-- DropIndex
DROP INDEX "users_settingsId_key";
-- AlterTable
ALTER TABLE "user_settings" ADD COLUMN "userId" TEXT;
-- AlterTable
ALTER TABLE "users" DROP COLUMN "settingsId";
-- AddForeignKey
ALTER TABLE "user_settings" ADD CONSTRAINT "user_settings_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View File

@ -1,11 +0,0 @@
/*
Warnings:
- You are about to drop the column `userId` on the `user_settings` table. All the data in the column will be lost.
*/
-- DropForeignKey
ALTER TABLE "user_settings" DROP CONSTRAINT "user_settings_userId_fkey";
-- AlterTable
ALTER TABLE "user_settings" DROP COLUMN "userId";

View File

@ -1,15 +0,0 @@
/*
Warnings:
- The `currency` column on the `pipelines` table would be dropped and recreated. This will lead to data loss if there is data in the column.
*/
-- CreateEnum
CREATE TYPE "CurrencyCode" AS ENUM ('AED', 'AFN', 'ALL', 'AMD', 'ANG', 'AOA', 'ARS', 'AUD', 'AWG', 'AZN', 'BAM', 'BBD', 'BDT', 'BGN', 'BHD', 'BIF', 'BMD', 'BND', 'BOB', 'BOV', 'BRL', 'BSD', 'BTN', 'BWP', 'BYN', 'BZD', 'CAD', 'CDF', 'CHF', 'CLF', 'CLP', 'CNY', 'COP', 'COU', 'CRC', 'CUC', 'CUP', 'CVE', 'CZK', 'DJF', 'DKK', 'DOP', 'DZD', 'EGP', 'ERN', 'ETB', 'EUR', 'FJD', 'FKP', 'GBP', 'GEL', 'GHS', 'GIP', 'GMD', 'GNF', 'GTQ', 'GYD', 'HKD', 'HNL', 'HRK', 'HTG', 'HUF', 'IDR', 'ILS', 'INR', 'IQD', 'IRR', 'ISK', 'JMD', 'JOD', 'JPY', 'KES', 'KGS', 'KHR', 'KMF', 'KPW', 'KRW', 'KWD', 'KYD', 'KZT', 'LAK', 'LBP', 'LKR', 'LRD', 'LSL', 'LYD', 'MAD', 'MDL', 'MGA', 'MKD', 'MMK', 'MNT', 'MOP', 'MRO', 'MRU', 'MUR', 'MVR', 'MWK', 'MXN', 'MXV', 'MYR', 'MZN', 'NAD', 'NGN', 'NIO', 'NOK', 'NPR', 'NZD', 'OMR', 'PAB', 'PEN', 'PGK', 'PHP', 'PKR', 'PLN', 'PYG', 'QAR', 'RON', 'RSD', 'RUB', 'RWF', 'SAR', 'SBD', 'SCR', 'SDD', 'SDG', 'SEK', 'SGD', 'SHP', 'SLL', 'SOS', 'SRD', 'SSP', 'STD', 'STN', 'SVC', 'SYP', 'SZL', 'THB', 'TJS', 'TMM', 'TMT', 'TND', 'TOP', 'TRY', 'TTD', 'TWD', 'TZS', 'UAH', 'UGX', 'USD', 'UYU', 'UZS', 'VEF', 'VES', 'VND', 'VUV', 'WST', 'XAF', 'XCD', 'XOF', 'XPF', 'XSU', 'XUA', 'YER', 'ZAR', 'ZMW', 'ZWL');
-- AlterTable
ALTER TABLE "pipelines" DROP COLUMN "currency",
ADD COLUMN "currency" "CurrencyCode" NOT NULL DEFAULT 'USD';
-- DropEnum
DROP TYPE "Currency";

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,9 +0,0 @@
import { Module } from '@nestjs/common';
import { PrismaService } from './prisma.service';
@Module({
providers: [PrismaService],
exports: [PrismaService],
})
export class PrismaModule {}

View File

@ -1,74 +0,0 @@
import {
INestApplication,
Injectable,
Logger,
OnModuleDestroy,
OnModuleInit,
} from '@nestjs/common';
import { Prisma, PrismaClient } from '@prisma/client';
import { createPrismaQueryEventHandler } from 'prisma-query-log';
import { EnvironmentService } from 'src/integrations/environment/environment.service';
// Prepare Prisma extenstion ability
const createPrismaClient = (options: Prisma.PrismaClientOptions) => {
const client = new PrismaClient(options);
return client;
};
type ExtendedPrismaClient = ReturnType<typeof createPrismaClient>;
@Injectable()
export class PrismaService implements OnModuleInit, OnModuleDestroy {
private readonly logger = new Logger(PrismaService.name);
private prismaClient!: ExtendedPrismaClient;
public get client(): ExtendedPrismaClient {
return this.prismaClient;
}
constructor(private readonly environmentService: EnvironmentService) {
const debugMode = environmentService.isDebugMode();
this.prismaClient = createPrismaClient({
errorFormat: 'minimal',
log: debugMode
? [
{
level: 'query',
emit: 'event',
},
]
: undefined,
});
if (debugMode) {
const logHandler = createPrismaQueryEventHandler({
logger: (query: string) => {
this.logger.log(query, 'PrismaClient');
},
format: false,
colorQuery: '\u001B[96m',
colorParameter: '\u001B[90m',
});
this.prismaClient.$on('query' as any, logHandler);
}
}
async onModuleInit(): Promise<void> {
await this.prismaClient.$connect();
}
async onModuleDestroy(): Promise<void> {
await this.prismaClient.$disconnect();
}
async enableShutdownHooks(app: INestApplication) {
this.prismaClient.$on('beforeExit', async () => {
await app.close();
});
}
}

View File

@ -1,831 +0,0 @@
generator client {
provider = "prisma-client-js"
engineType = "binary"
}
datasource db {
provider = "postgresql"
url = env("PG_DATABASE_URL")
}
generator nestgraphql {
provider = "node node_modules/prisma-nestjs-graphql"
output = "../../src/core/@generated"
noAtomicOperations = true
// field validator
fields_Validator_input = true
fields_Validator_output = true
fields_Validator_model = true
fields_Validator_from = "class-validator"
// All relations, only allow connect
decorate_all_type = "!(ActivityTarget*Input|UserSettingsUpdateOneRequiredWithoutUserNestedInput)"
decorate_all_field = "*(create|connectOrCreate|update|upsert|delete|createMany|updateMany|deleteMany)"
decorate_all_name = "HideField"
decorate_all_from = "@nestjs/graphql"
decorate_all_arguments = "[]"
// Activity: Only Allow targets createOrConnect / createMany
decorate_activityTargets_type = "*ActivityTarget*Input"
decorate_activityTargets_field = "*(update|upsert|updateMany)"
decorate_activityTargets_name = "HideField"
decorate_activityTargets_from = "@nestjs/graphql"
decorate_activityTargets_arguments = "[]"
// User Settings: Only Allow targets createOrConnect / createMany
decorate_userSettings_type = "*UserSettingsUpdateOneRequiredWithoutUserNestedInput"
decorate_userSettings_field = "!(update)"
decorate_userSettings_name = "HideField"
decorate_userSettings_from = "@nestjs/graphql"
decorate_userSettings_arguments = "[]"
// Disable _count on all models except Aggregation use case
decorate_count_type = "!(*Aggregate*|*GroupBy*|*OrderBy*)"
decorate_count_field = "_count"
decorate_count_name = "HideField"
decorate_count_from = "@nestjs/graphql"
decorate_count_arguments = "[]"
// create data validator
decorate_classValidator_type = "@(Create|Update|Upsert)*Args"
decorate_classValidator_field = "@(data|[A-Z]*)"
decorate_classValidator_name = ValidateNested
decorate_classValidator_from = "class-validator"
decorate_classValidator_arguments = "['{each: true}']"
// create data transformer
decorate_classTransformer_type = "@(Create|Update|Upsert)*Args"
decorate_classTransformer_field = "@(data|[A-Z]*)"
decorate_classTransformer_from = "class-transformer"
decorate_classTransformer_arguments = "['() => {propertyType.0}']"
decorate_classTransformer_name = Type
}
model User {
/// @Validator.IsString()
/// @Validator.IsOptional()
id String @id @default(uuid())
/// @Validator.IsString()
/// @Validator.IsOptional()
firstName String?
/// @Validator.IsString()
/// @Validator.IsOptional()
lastName String?
/// @Validator.IsEmail()
/// @Validator.IsOptional()
email String @unique
/// @Validator.IsBoolean()
/// @Validator.IsOptional()
emailVerified Boolean @default(false)
/// @Validator.IsString()
/// @Validator.IsOptional()
avatarUrl String?
/// @Validator.IsString()
/// @Validator.IsOptional()
locale String
/// @Validator.IsString()
/// @Validator.IsOptional()
phoneNumber String?
/// @Validator.IsDate()
/// @Validator.IsOptional()
lastSeen DateTime?
/// @Validator.IsBoolean()
/// @Validator.IsOptional()
disabled Boolean @default(false)
/// @TypeGraphQL.omit(input: true, output: true)
passwordHash String?
/// @Validator.IsJSON()
/// @Validator.IsOptional()
metadata Json?
/// @Validator.IsBoolean()
/// @Validator.IsOptional()
canImpersonate Boolean @default(false)
companies Company[]
/// @TypeGraphQL.omit(input: true, output: true)
refreshTokens RefreshToken[]
comments Comment[]
defaultWorkspaceId String?
authoredActivities Activity[] @relation(name: "authoredActivities")
assignedActivities Activity[] @relation(name: "assignedActivities")
authoredAttachments Attachment[] @relation(name: "authoredAttachments")
/// @TypeGraphQL.omit(input: true, output: true)
deletedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@map("users")
}
enum ColorScheme {
Light
Dark
System
}
model UserSettings {
id String @id @default(uuid())
/// @Validator.IsString()
/// @Validator.IsOptional()
colorScheme ColorScheme @default(System)
/// @Validator.IsString()
locale String
WorkspaceMember WorkspaceMember[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@map("user_settings")
}
/// @TypeGraphQL.omit(input: true)
model Workspace {
/// @Validator.IsString()
/// @Validator.IsOptional()
id String @id @default(uuid())
/// @Validator.IsString()
/// @Validator.IsOptional()
domainName String?
/// @Validator.IsString()
/// @Validator.IsOptional()
displayName String?
/// @Validator.IsString()
/// @Validator.IsOptional()
logo String?
/// @Validator.IsString()
/// @Validator.IsOptional()
inviteHash String?
workspaceMember WorkspaceMember[]
companies Company[]
people Person[]
activities Activity[]
comments Comment[]
pipelines Pipeline[]
pipelineStages PipelineStage[]
pipelineProgresses PipelineProgress[]
activityTargets ActivityTarget[]
apiKeys ApiKey[]
webHooks WebHook[]
/// @TypeGraphQL.omit(input: true, output: true)
deletedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
Attachment Attachment[]
@@map("workspaces")
}
model WorkspaceMember {
/// @Validator.IsString()
/// @Validator.IsOptional()
id String @id @default(uuid())
/// @Validator.IsBoolean()
/// @Validator.IsOptional()
allowImpersonation Boolean @default(true)
userId String @unique
/// @TypeGraphQL.omit(input: true, output: false)
workspace Workspace @relation(fields: [workspaceId], references: [id])
/// @TypeGraphQL.omit(input: true, output: true)
workspaceId String
/// @TypeGraphQL.omit(input: true, output: true)
deletedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
Favorite Favorite[]
authoredActivities Activity[] @relation(name: "authoredActivities")
assignedActivities Activity[] @relation(name: "assignedActivities")
authoredAttachments Attachment[] @relation(name: "authoredAttachments")
settings UserSettings? @relation(fields: [settingsId], references: [id])
settingsId String?
companies Company[]
comments Comment[]
@@map("workspace_members")
}
model Company {
/// @Validator.IsString()
/// @Validator.IsOptional()
id String @id @default(uuid())
/// @Validator.IsString()
/// @Validator.IsOptional()
name String
/// @Validator.IsString()
/// @Validator.IsOptional()
domainName String
/// @Validator.IsString()
/// @Validator.IsOptional()
linkedinUrl String?
/// @Validator.IsNumber()
/// @Validator.IsOptional()
annualRecurringRevenue Int?
/// @Validator.IsBoolean()
/// @Validator.IsOptional()
idealCustomerProfile Boolean @default(false)
/// @Validator.IsString()
/// @Validator.IsOptional()
xUrl String?
/// @Validator.IsString()
/// @Validator.IsOptional()
address String
/// @Validator.IsNumber()
/// @Validator.IsOptional()
employees Int?
people Person[]
accountOwner User? @relation(fields: [accountOwnerId], references: [id], onDelete: SetNull)
accountOwnerId String?
workspaceMemberAccountOwner WorkspaceMember? @relation(fields: [workspaceMemberAccountOwnerId], references: [id], onDelete: SetNull)
workspaceMemberAccountOwnerId String?
/// @TypeGraphQL.omit(input: true, output: true)
workspace Workspace @relation(fields: [workspaceId], references: [id])
/// @TypeGraphQL.omit(input: true, output: true)
workspaceId String
/// @TypeGraphQL.omit(input: true, output: true)
deletedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
ActivityTarget ActivityTarget[]
PipelineProgress PipelineProgress[]
Favorite Favorite[]
Attachment Attachment[]
@@map("companies")
}
model Person {
/// @Validator.IsString()
/// @Validator.IsOptional()
id String @id @default(uuid())
/// @Validator.IsString()
/// @Validator.IsOptional()
firstName String?
/// @Validator.IsString()
/// @Validator.IsOptional()
lastName String?
/// @Validator.IsString()
/// @Validator.IsOptional()
email String?
/// @Validator.IsString()
/// @Validator.IsOptional()
linkedinUrl String?
/// @Validator.IsString()
/// @Validator.IsOptional()
xUrl String?
/// @Validator.IsString()
/// @Validator.IsOptional()
jobTitle String?
/// @Validator.IsString()
/// @Validator.IsOptional()
phone String?
/// @Validator.IsString()
/// @Validator.IsOptional()
city String?
/// @Validator.IsString()
/// @Validator.IsOptional()
avatarUrl String?
company Company? @relation(fields: [companyId], references: [id], onDelete: SetNull)
companyId String?
/// @TypeGraphQL.omit(input: true, output: true)
workspace Workspace @relation(fields: [workspaceId], references: [id])
/// @TypeGraphQL.omit(input: true, output: true)
workspaceId String
contactPipelineProgresses PipelineProgress[] @relation("PointOfContactPipelineProgress")
/// @TypeGraphQL.omit(input: true, output: true)
deletedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
ActivityTarget ActivityTarget[]
PipelineProgress PipelineProgress[]
Favorite Favorite[]
Attachment Attachment[]
@@map("people")
}
model RefreshToken {
/// @Validator.IsString()
/// @Validator.IsOptional()
id String @id @default(uuid())
/// @TypeGraphQL.omit(input: true, output: true)
user User @relation(fields: [userId], references: [id])
/// @TypeGraphQL.omit(input: true, output: true)
userId String
expiresAt DateTime
/// @TypeGraphQL.omit(input: true, output: true)
deletedAt DateTime?
/// @TypeGraphQL.omit(input: true, output: true)
revokedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@map("refresh_tokens")
}
enum ActivityType {
Note
Task
}
model Activity {
/// @Validator.IsString()
/// @Validator.IsOptional()
id String @id @default(uuid())
body String?
title String?
type ActivityType @default(Note)
reminderAt DateTime?
dueAt DateTime?
completedAt DateTime?
activityTargets ActivityTarget[]
comments Comment[]
attachments Attachment[]
author User @relation(fields: [authorId], references: [id], name: "authoredActivities", onDelete: Cascade)
authorId String
workspaceMemberAuthor WorkspaceMember? @relation(fields: [workspaceMemberAuthorId], references: [id], name: "authoredActivities", onDelete: Cascade)
workspaceMemberAuthorId String?
assignee User? @relation(fields: [assigneeId], references: [id], name: "assignedActivities", onDelete: SetNull)
assigneeId String?
workspaceMemberAssignee WorkspaceMember? @relation(fields: [workspaceMemberAssigneeId], references: [id], name: "assignedActivities", onDelete: SetNull)
workspaceMemberAssigneeId String?
/// @TypeGraphQL.omit(input: true, output: true)
workspace Workspace @relation(fields: [workspaceId], references: [id])
/// @TypeGraphQL.omit(input: true, output: true)
workspaceId String
/// @TypeGraphQL.omit(input: true, output: true)
deletedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@map("activities")
}
model Comment {
/// @Validator.IsString()
/// @Validator.IsOptional()
id String @id @default(uuid())
/// @Validator.IsString()
body String
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
authorId String
workspaceMemberAuthor WorkspaceMember? @relation(fields: [workspaceMemberAuthorId], references: [id], onDelete: Cascade)
workspaceMemberAuthorId String?
activity Activity? @relation(fields: [activityId], references: [id], onDelete: Cascade)
activityId String?
commentThreadId String?
/// @TypeGraphQL.omit(input: true, output: true)
workspace Workspace @relation(fields: [workspaceId], references: [id])
/// @TypeGraphQL.omit(input: true, output: true)
workspaceId String
/// @TypeGraphQL.omit(input: true, output: true)
deletedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@map("comments")
}
model ActivityTarget {
/// @Validator.IsString()
/// @Validator.IsOptional()
id String @id @default(uuid())
activity Activity @relation(fields: [activityId], references: [id], onDelete: Cascade)
activityId String
/// @TypeGraphQL.omit(input: true, output: true)
workspace Workspace @relation(fields: [workspaceId], references: [id])
/// @TypeGraphQL.omit(input: true, output: true)
workspaceId String
personId String?
person Person? @relation(fields: [personId], references: [id], onDelete: Cascade)
companyId String?
company Company? @relation(fields: [companyId], references: [id], onDelete: Cascade)
/// @TypeGraphQL.omit(input: true, output: true)
deletedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@map("activity_targets")
}
// All of the world's currently active currencies based on the ISO 4217 standard
enum CurrencyCode {
AED
AFN
ALL
AMD
ANG
AOA
ARS
AUD
AWG
AZN
BAM
BBD
BDT
BGN
BHD
BIF
BMD
BND
BOB
BOV
BRL
BSD
BTN
BWP
BYN
BZD
CAD
CDF
CHF
CLF
CLP
CNY
COP
COU
CRC
CUC
CUP
CVE
CZK
DJF
DKK
DOP
DZD
EGP
ERN
ETB
EUR
FJD
FKP
GBP
GEL
GHS
GIP
GMD
GNF
GTQ
GYD
HKD
HNL
HRK
HTG
HUF
IDR
ILS
INR
IQD
IRR
ISK
JMD
JOD
JPY
KES
KGS
KHR
KMF
KPW
KRW
KWD
KYD
KZT
LAK
LBP
LKR
LRD
LSL
LYD
MAD
MDL
MGA
MKD
MMK
MNT
MOP
MRO
MRU
MUR
MVR
MWK
MXN
MXV
MYR
MZN
NAD
NGN
NIO
NOK
NPR
NZD
OMR
PAB
PEN
PGK
PHP
PKR
PLN
PYG
QAR
RON
RSD
RUB
RWF
SAR
SBD
SCR
SDD
SDG
SEK
SGD
SHP
SLL
SOS
SRD
SSP
STD
STN
SVC
SYP
SZL
THB
TJS
TMM
TMT
TND
TOP
TRY
TTD
TWD
TZS
UAH
UGX
USD
UYU
UZS
VEF
VES
VND
VUV
WST
XAF
XCD
XOF
XPF
XSU
XUA
YER
ZAR
ZMW
ZWL
@@map("CurrencyCode")
}
model Pipeline {
/// @Validator.IsString()
/// @Validator.IsOptional()
id String @id @default(uuid())
/// @Validator.IsString()
name String
/// @Validator.IsString()
icon String
pipelineStages PipelineStage[]
pipelineProgresses PipelineProgress[]
pipelineProgressableType PipelineProgressableType @default(Company)
/// @TypeGraphQL.omit(input: true, output: true)
workspace Workspace @relation(fields: [workspaceId], references: [id])
/// @TypeGraphQL.omit(input: true, output: true)
workspaceId String
/// @TypeGraphQL.omit(input: true, output: true)
deletedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
currency CurrencyCode @default(USD)
@@map("pipelines")
}
model PipelineStage {
/// @Validator.IsString()
/// @Validator.IsOptional()
id String @id @default(uuid())
/// @Validator.IsString()
/// @Validator.IsOptional()
name String
/// @Validator.IsString()
/// @Validator.IsOptional()
type String
/// @Validator.IsOptional()
/// @Validator.IsString()
color String
/// @Validator.IsNumber()
/// @Validator.IsOptional()
position Int?
pipelineProgresses PipelineProgress[]
///
pipeline Pipeline @relation(fields: [pipelineId], references: [id], onDelete: Cascade)
pipelineId String
/// @TypeGraphQL.omit(input: true, output: true)
workspace Workspace @relation(fields: [workspaceId], references: [id])
/// @TypeGraphQL.omit(input: true, output: true)
workspaceId String
/// @TypeGraphQL.omit(input: true, output: true)
deletedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@map("pipeline_stages")
}
enum PipelineProgressableType {
Person
Company
}
model PipelineProgress {
/// @Validator.IsString()
/// @Validator.IsOptional()
id String @id @default(uuid())
amount Int?
closeDate DateTime?
probability Int?
pipeline Pipeline @relation(fields: [pipelineId], references: [id], onDelete: Cascade)
pipelineId String
pipelineStage PipelineStage @relation(fields: [pipelineStageId], references: [id], onDelete: Cascade)
pipelineStageId String
pointOfContact Person? @relation("PointOfContactPipelineProgress", fields: [pointOfContactId], references: [id], onDelete: SetNull)
pointOfContactId String?
/// @TypeGraphQL.omit(input: true, output: true)
workspace Workspace @relation(fields: [workspaceId], references: [id])
/// @TypeGraphQL.omit(input: true, output: true)
workspaceId String
/// @TypeGraphQL.omit(input: true, output: true)
deletedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
companyId String?
company Company? @relation(fields: [companyId], references: [id], onDelete: Cascade)
personId String?
person Person? @relation(fields: [personId], references: [id], onDelete: Cascade)
@@map("pipeline_progresses")
}
enum AttachmentType {
Image
Audio
Video
TextDocument
Spreadsheet
Archive
Other
}
model Attachment {
/// @Validator.IsString()
/// @Validator.IsOptional()
id String @id @default(uuid())
fullPath String
type AttachmentType
name String
/// @TypeGraphQL.omit(input: true, output: true)
workspaceId String
author User @relation(fields: [authorId], references: [id], name: "authoredAttachments", onDelete: Cascade)
authorId String
workspaceMemberAuthor WorkspaceMember? @relation(fields: [workspaceMemberAuthorId], references: [id], name: "authoredAttachments", onDelete: Cascade)
workspaceMemberAuthorId String?
activity Activity? @relation(fields: [activityId], references: [id], onDelete: Cascade)
activityId String?
/// @TypeGraphQL.omit(input: true, output: false)
person Person? @relation(fields: [personId], references: [id], onDelete: Cascade)
personId String?
/// @TypeGraphQL.omit(input: true, output: false)
company Company? @relation(fields: [companyId], references: [id], onDelete: Cascade)
companyId String?
/// @TypeGraphQL.omit(input: true, output: false)
workspace Workspace @relation(fields: [workspaceId], references: [id])
/// @TypeGraphQL.omit(input: true, output: true)
deletedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@map("attachments")
}
model Favorite {
id String @id @default(uuid())
workspaceId String?
/// @TypeGraphQL.omit(input: true, output: false)
person Person? @relation(fields: [personId], references: [id], onDelete: Cascade)
personId String?
/// @TypeGraphQL.omit(input: true, output: false)
company Company? @relation(fields: [companyId], references: [id], onDelete: Cascade)
companyId String?
/// @TypeGraphQL.omit(input: true, output: false)
workspaceMember WorkspaceMember? @relation(fields: [workspaceMemberId], references: [id])
workspaceMemberId String?
position Float
@@map("favorites")
}
enum ViewType {
Table
Pipeline
}
model ApiKey {
/// @Validator.IsString()
/// @Validator.IsOptional()
id String @id @default(uuid())
name String
/// @TypeGraphQL.omit(input: true, output: true)
workspace Workspace @relation(fields: [workspaceId], references: [id])
/// @TypeGraphQL.omit(input: true, output: true)
workspaceId String
expiresAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
/// @TypeGraphQL.omit(input: true, output: true)
deletedAt DateTime?
/// @TypeGraphQL.omit(input: true, output: true)
revokedAt DateTime?
@@map("api_keys")
}
model WebHook {
/// @Validator.IsString()
/// @Validator.IsOptional()
id String @id @default(uuid())
/// @TypeGraphQL.omit(input: true, output: true)
workspace Workspace @relation(fields: [workspaceId], references: [id])
/// @TypeGraphQL.omit(input: true, output: true)
workspaceId String
targetUrl String
operation String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
/// @TypeGraphQL.omit(input: true, output: true)
deletedAt DateTime?
@@map("web_hooks")
}

View File

@ -1,130 +0,0 @@
import { PrismaClient } from '@prisma/client';
export const seedComments = async (prisma: PrismaClient) => {
await prisma.activity.upsert({
where: { id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400' },
update: {},
create: {
id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
title: 'Performance update',
type: 'Note',
body: '[{"id":"555df0c3-ab88-4c62-abae-c9b557c37c5b","type":"paragraph","props":{"textColor":"default","backgroundColor":"default","textAlignment":"left"},"content":[{"type":"text","text":"In the North American region, we have observed a strong growth rate of 18% in sales. Europe followed suit with a significant 14% increase, while Asia-Pacific sustained its performance with a steady 10% rise. Special kudos to the North American team for the excellent work done in penetrating new markets and establishing stronger footholds in the existing ones.","styles":{}}],"children":[]},{"id":"13530934-b3ce-4332-9238-3760aa4acb3e","type":"paragraph","props":{"textColor":"default","backgroundColor":"default","textAlignment":"left"},"content":[],"children":[]}]',
authorId: '20202020-c231-45c5-b9f2-cf8b70191f6d',
},
});
await prisma.activityTarget.upsert({
where: { id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb600' },
update: {},
create: {
id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb600',
personId: null,
companyId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfa408',
activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
},
});
await prisma.comment.upsert({
where: { id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb200' },
update: {},
create: {
id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb200',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
body: 'Hi Félix ! How do you like your Twenty workspace?',
activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400',
commentThreadId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400',
authorId: '20202020-c231-45c5-b9f2-cf8b70191f6d',
},
});
await prisma.comment.upsert({
where: { id: 'twenty-fe256b40-3ec3-4fe3-8997-b76aa0bfb200' },
update: {},
create: {
id: 'twenty-fe256b40-3ec3-4fe3-8997-b76aa0bfb200',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
body: 'I love it!',
activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400',
commentThreadId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400',
authorId: '20202020-ef2e-45df-b677-32fa06d4bd2a',
},
});
await prisma.activity.upsert({
where: { id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfc408' },
update: {},
create: {
id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfc408',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
title: 'Buyout Proposal',
type: 'Task',
assigneeId: '20202020-c231-45c5-b9f2-cf8b70191f6d',
dueAt: new Date('2021-03-01T00:00:00.000Z'),
body: '[{"id":"333df0c3-ab88-4c62-abae-c9b557c37c5b","type":"paragraph","props":{"textColor":"default","backgroundColor":"default","textAlignment":"left"},"content":[{"type":"text","text":"We are considering the potential acquisition of [Company], a leading company in [Industry/Specific Technology]. This company has demonstrated remarkable success and pioneering advancements in their field, paralleling our own commitment to progress. By integrating their expertise with our own, we believe that we can amplify our growth, broaden our offerings, and fortify our position at the forefront of technology. This prospective partnership could help to ensure our continued leadership in the industry and allow us to deliver even more innovative solutions for our customers.","styles":{}}],"children":[]},{"id":"13530934-b3ce-4332-9238-3760aa4acb3e","type":"paragraph","props":{"textColor":"default","backgroundColor":"default","textAlignment":"left"},"content":[],"children":[]}]',
authorId: '20202020-c231-45c5-b9f2-cf8b70191f6d',
},
});
await prisma.activityTarget.upsert({
where: { id: 'twenty-fe256b39-3ec3-4fe3-8997-a76aa0bfb600' },
update: {},
create: {
id: 'twenty-fe256b39-3ec3-4fe3-8997-a76aa0bfb600',
personId: 'twenty-755035db-623d-41fe-92e7-dd45b7c568e1',
companyId: null,
activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfc408',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
},
});
await prisma.comment.upsert({
where: { id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb100' },
update: {},
create: {
id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb100',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
body: 'I really like this comment thread feature!',
activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfc408',
commentThreadId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfc408',
authorId: '20202020-c231-45c5-b9f2-cf8b70191f6d',
},
});
await prisma.activity.upsert({
where: { id: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b76aaabfb408' },
update: {},
create: {
id: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b76aaabfb408',
workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
title: 'Call summary',
body: '[{"id":"555df0c3-ab88-4c62-abae-c9b557c37c5b","type":"paragraph","props":{"textColor":"default","backgroundColor":"default","textAlignment":"left"},"content":[{"type":"text","text":"Valuation & Due Diligence: The CFO highlighted the financial implications, pointing out that the acquisition will be accretive to earnings. The M&A team has been directed to commence due diligence and work closely with legal counsel to assess all aspects of the acquisition.","styles":{}}],"children":[]},{"id":"13530934-b3ce-4332-9238-3760aa4acb3e","type":"paragraph","props":{"textColor":"default","backgroundColor":"default","textAlignment":"left"},"content":[],"children":[]}]',
authorId: 'twenty-dev-gk256b39-3ec3-4fe3-8997-b76aa0boa408',
},
});
await prisma.activityTarget.upsert({
where: { id: 'twenty-dev-fe256b39-3ec3-4fe3-8997-a76aa0bfba00' },
update: {},
create: {
id: 'twenty-dev-fe256b39-3ec3-4fe3-8997-a76aa0bfba00',
personId: null,
companyId: 'twenty-dev-a674fa6c-1455-4c57-afaf-dd5dc086361e',
activityId: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b76aaabfb408',
workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
},
});
await prisma.comment.upsert({
where: { id: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b76aa0bfb000' },
update: {},
create: {
id: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b76aa0bfb000',
workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
body: 'I really like this comment thread feature!',
activityId: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b76aaabfb408',
commentThreadId: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b76aaabfb408',
authorId: 'twenty-dev-gk256b39-3ec3-4fe3-8997-b76aa0boa408',
},
});
};

View File

@ -1,162 +0,0 @@
import { PrismaClient } from '@prisma/client';
export const seedCompanies = async (prisma: PrismaClient) => {
await prisma.company.upsert({
where: { id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfa408' },
update: {},
create: {
id: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfa408',
name: 'Linkedin',
domainName: 'linkedin.com',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '',
},
});
await prisma.company.upsert({
where: { id: 'twenty-118995f3-5d81-46d6-bf83-f7fd33ea6102' },
update: {},
create: {
id: 'twenty-118995f3-5d81-46d6-bf83-f7fd33ea6102',
name: 'Facebook',
domainName: 'facebook.com',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '',
},
});
await prisma.company.upsert({
where: { id: 'twenty-04b2e9f5-0713-40a5-8216-82802401d33e' },
update: {},
create: {
id: 'twenty-04b2e9f5-0713-40a5-8216-82802401d33e',
name: 'Qonto',
domainName: 'qonto.com',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '',
},
});
await prisma.company.upsert({
where: { id: 'twenty-460b6fb1-ed89-413a-b31a-962986e67bb4' },
update: {},
create: {
id: 'twenty-460b6fb1-ed89-413a-b31a-962986e67bb4',
name: 'Microsoft',
domainName: 'microsoft.com',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '',
},
});
await prisma.company.upsert({
where: { id: 'twenty-89bb825c-171e-4bcc-9cf7-43448d6fb278' },
update: {},
create: {
id: 'twenty-89bb825c-171e-4bcc-9cf7-43448d6fb278',
name: 'Airbnb',
domainName: 'airbnb.com',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '',
},
});
await prisma.company.upsert({
where: { id: 'twenty-0d940997-c21e-4ec2-873b-de4264d89025' },
update: {},
create: {
id: 'twenty-0d940997-c21e-4ec2-873b-de4264d89025',
name: 'Google',
domainName: 'google.com',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '',
},
});
await prisma.company.upsert({
where: { id: 'twenty-1d3a1c6e-707e-44dc-a1d2-30030bf1a944' },
update: {},
create: {
id: 'twenty-1d3a1c6e-707e-44dc-a1d2-30030bf1a944',
name: 'Netflix',
domainName: 'netflix.com',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '',
},
});
await prisma.company.upsert({
where: { id: 'twenty-7a93d1e5-3f74-492d-a101-2a70f50a1645' },
update: {},
create: {
id: 'twenty-7a93d1e5-3f74-492d-a101-2a70f50a1645',
name: 'Libeo',
domainName: 'libeo.io',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '',
},
});
await prisma.company.upsert({
where: { id: 'twenty-9d162de6-cfbf-4156-a790-e39854dcd4eb' },
update: {},
create: {
id: 'twenty-9d162de6-cfbf-4156-a790-e39854dcd4eb',
name: 'Claap',
domainName: 'claap.io',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '',
},
});
await prisma.company.upsert({
where: { id: 'twenty-aaffcfbd-f86b-419f-b794-02319abe8637' },
update: {},
create: {
id: 'twenty-aaffcfbd-f86b-419f-b794-02319abe8637',
name: 'Hasura',
domainName: 'hasura.io',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '',
},
});
await prisma.company.upsert({
where: { id: 'twenty-f33dc242-5518-4553-9433-42d8eb82834b' },
update: {},
create: {
id: 'twenty-f33dc242-5518-4553-9433-42d8eb82834b',
name: 'Wework',
domainName: 'wework.com',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '',
},
});
await prisma.company.upsert({
where: { id: 'twenty-a7bc68d5-f79e-40dd-bd06-c36e6abb4678' },
update: {},
create: {
id: 'twenty-a7bc68d5-f79e-40dd-bd06-c36e6abb4678',
name: 'Samsung',
domainName: 'samsung.com',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '',
},
});
await prisma.company.upsert({
where: { id: 'twenty-a674fa6c-1455-4c57-afaf-dd5dc086361d' },
update: {},
create: {
id: 'twenty-a674fa6c-1455-4c57-afaf-dd5dc086361d',
name: 'Algolia',
domainName: 'algolia.com',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
address: '',
},
});
await prisma.company.upsert({
where: { id: 'twenty-dev-a674fa6c-1455-4c57-afaf-dd5dc086361e' },
update: {},
create: {
id: 'twenty-dev-a674fa6c-1455-4c57-afaf-dd5dc086361e',
name: 'Instagram',
domainName: 'instagram.com',
workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
address: '',
},
});
};

View File

@ -1,23 +0,0 @@
import { PrismaClient } from '@prisma/client';
import { seedCompanies } from './companies';
import { seedWorkspaces } from './workspaces';
import { seedPeople } from './people';
import { seedComments } from './comments';
import { seedUsers } from './users';
import { seedPipelines } from './pipelines';
import { seedMetadata } from './metadata';
const seed = async () => {
const prisma = new PrismaClient();
await seedWorkspaces(prisma);
await seedUsers(prisma);
await seedCompanies(prisma);
await seedPeople(prisma);
await seedComments(prisma);
await seedPipelines(prisma);
await seedMetadata(prisma);
await prisma.$disconnect();
};
seed();

View File

@ -1,19 +0,0 @@
import { PrismaClient } from '@prisma/client';
export const SeedDataSourceId = '20202020-7f63-47a9-b1b3-6c7290ca9fb1';
export const SeedWorkspaceId = '20202020-1c25-4d02-bf25-6aeccf7ea419';
export const SeedWorkspaceSchemaName = 'workspace_1wgvd1injqtife6y4rvfbu3h5';
export const seedMetadata = async (prisma: PrismaClient) => {
await prisma.$queryRawUnsafe(
`CREATE SCHEMA IF NOT EXISTS ${SeedWorkspaceSchemaName}`,
);
await prisma.$queryRawUnsafe(
`INSERT INTO metadata."dataSource"(
id, schema, type, "workspaceId"
)
VALUES (
'${SeedDataSourceId}', '${SeedWorkspaceSchemaName}', 'postgres', '${SeedWorkspaceId}'
) ON CONFLICT DO NOTHING`,
);
};

View File

@ -1,227 +0,0 @@
import { PrismaClient } from '@prisma/client';
export const seedPeople = async (prisma: PrismaClient) => {
await prisma.person.upsert({
where: { id: 'twenty-86083141-1c0e-494c-a1b6-85b1c6fefaa5' },
update: {},
create: {
id: 'twenty-86083141-1c0e-494c-a1b6-85b1c6fefaa5',
firstName: 'Christoph',
lastName: 'Callisto',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33789012345',
city: 'Seattle',
companyId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfa408',
email: 'christoph.calisto@linkedin.com',
},
});
await prisma.person.upsert({
where: { id: 'twenty-0aa00beb-ac73-4797-824e-87a1f5aea9e0' },
update: {},
create: {
id: 'twenty-0aa00beb-ac73-4797-824e-87a1f5aea9e0',
firstName: 'Sylvie',
lastName: 'Palmer',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33780123456',
city: 'Los Angeles',
companyId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfa408',
email: 'sylvie.palmer@linkedin.com',
},
});
await prisma.person.upsert({
where: { id: 'twenty-93c72d2e-f517-42fd-80ae-14173b3b70ae' },
update: {},
create: {
id: 'twenty-93c72d2e-f517-42fd-80ae-14173b3b70ae',
firstName: 'Christopher',
lastName: 'Gonzalez',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33789012345',
city: 'Seattle',
companyId: 'twenty-04b2e9f5-0713-40a5-8216-82802401d33e',
email: 'christopher.gonzalez@qonto.com',
},
});
await prisma.person.upsert({
where: { id: 'twenty-eeeacacf-eee1-4690-ad2c-8619e5b56a2e' },
update: {},
create: {
id: 'twenty-eeeacacf-eee1-4690-ad2c-8619e5b56a2e',
firstName: 'Ashley',
lastName: 'Parker',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33780123456',
city: 'Los Angeles',
companyId: 'twenty-04b2e9f5-0713-40a5-8216-82802401d33e',
email: 'ashley.parker@qonto.com',
},
});
await prisma.person.upsert({
where: { id: 'twenty-9b324a88-6784-4449-afdf-dc62cb8702f2' },
update: {},
create: {
id: 'twenty-9b324a88-6784-4449-afdf-dc62cb8702f2',
firstName: 'Nicholas',
lastName: 'Wright',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33781234567',
city: 'Seattle',
companyId: 'twenty-460b6fb1-ed89-413a-b31a-962986e67bb4',
email: 'nicholas.wright@microsoft.com',
},
});
await prisma.person.upsert({
where: { id: 'twenty-1d151852-490f-4466-8391-733cfd66a0c8' },
update: {},
create: {
id: 'twenty-1d151852-490f-4466-8391-733cfd66a0c8',
firstName: 'Isabella',
lastName: 'Scott',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33782345678',
city: 'New York',
companyId: 'twenty-460b6fb1-ed89-413a-b31a-962986e67bb4',
email: 'isabella.scott@microsoft.com',
},
});
await prisma.person.upsert({
where: { id: 'twenty-98406e26-80f1-4dff-b570-a74942528de3' },
update: {},
create: {
id: 'twenty-98406e26-80f1-4dff-b570-a74942528de3',
firstName: 'Matthew',
lastName: 'Green',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33783456789',
city: 'Seattle',
companyId: 'twenty-460b6fb1-ed89-413a-b31a-962986e67bb4',
email: 'matthew.green@microsoft.com',
},
});
await prisma.person.upsert({
where: { id: 'twenty-a2e78a5f-338b-46df-8811-fa08c7d19d35' },
update: {},
create: {
id: 'twenty-a2e78a5f-338b-46df-8811-fa08c7d19d35',
firstName: 'Elizabeth',
lastName: 'Baker',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33784567890',
city: 'New York',
companyId: 'twenty-89bb825c-171e-4bcc-9cf7-43448d6fb278',
email: 'elizabeth.baker@airbnb.com',
},
});
await prisma.person.upsert({
where: { id: 'twenty-ca1f5bf3-64ad-4b0e-bbfd-e9fd795b7016' },
update: {},
create: {
id: 'twenty-ca1f5bf3-64ad-4b0e-bbfd-e9fd795b7016',
firstName: 'Christopher',
lastName: 'Nelson',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33785678901',
city: 'San Francisco',
companyId: 'twenty-89bb825c-171e-4bcc-9cf7-43448d6fb278',
email: 'christopher.nelson@airbnb.com',
},
});
await prisma.person.upsert({
where: { id: 'twenty-56955422-5d54-41b7-ba36-f0d20e1417ae' },
update: {},
create: {
id: 'twenty-56955422-5d54-41b7-ba36-f0d20e1417ae',
firstName: 'Avery',
lastName: 'Carter',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33786789012',
city: 'New York',
companyId: 'twenty-89bb825c-171e-4bcc-9cf7-43448d6fb278',
email: 'avery.carter@airbnb.com',
},
});
await prisma.person.upsert({
where: { id: 'twenty-755035db-623d-41fe-92e7-dd45b7c568e1' },
update: {},
create: {
id: 'twenty-755035db-623d-41fe-92e7-dd45b7c568e1',
firstName: 'Ethan',
lastName: 'Mitchell',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33787890123',
city: 'Los Angeles',
companyId: 'twenty-0d940997-c21e-4ec2-873b-de4264d89025',
email: 'ethan.mitchell@google.com',
},
});
await prisma.person.upsert({
where: { id: 'twenty-240da2ec-2d40-4e49-8df4-9c6a049190ef' },
update: {},
create: {
id: 'twenty-240da2ec-2d40-4e49-8df4-9c6a049190ef',
firstName: 'Madison',
lastName: 'Perez',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33788901234',
city: 'Seattle',
companyId: 'twenty-0d940997-c21e-4ec2-873b-de4264d89025',
email: 'madison.perez@google.com',
},
});
await prisma.person.upsert({
where: { id: 'twenty-240da2ec-2d40-4e49-8df4-9c6a049190df' },
update: {},
create: {
id: 'twenty-240da2ec-2d40-4e49-8df4-9c6a049190df',
firstName: 'Bertrand',
lastName: 'Voulzy',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33788901234',
city: 'Seattle',
companyId: 'twenty-0d940997-c21e-4ec2-873b-de4264d89025',
email: 'bertrand.voulzy@google.com',
},
});
await prisma.person.upsert({
where: { id: 'twenty-240da2ec-2d40-4e49-8df4-9c6a049190dg' },
update: {},
create: {
id: 'twenty-240da2ec-2d40-4e49-8df4-9c6a049190dg',
firstName: 'Louis',
lastName: 'Duss',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
phone: '+33788901234',
city: 'Seattle',
companyId: 'twenty-0d940997-c21e-4ec2-873b-de4264d89025',
email: 'louis.duss@google.com',
},
});
await prisma.person.upsert({
where: { id: 'twenty-dev-240da2ec-2d40-4e49-8df4-9c6a049190dh' },
update: {},
create: {
id: 'twenty-dev-240da2ec-2d40-4e49-8df4-9c6a049190dh',
firstName: 'Lorie',
lastName: 'Vladim',
workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
phone: '+33788901235',
city: 'Seattle',
companyId: 'twenty-dev-a674fa6c-1455-4c57-afaf-dd5dc086361e',
email: 'lorie.vladim@google.com',
},
});
};

View File

@ -1,251 +0,0 @@
import { PrismaClient } from '@prisma/client';
export const seedPipelines = async (prisma: PrismaClient) => {
await prisma.pipeline.upsert({
where: { id: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400' },
update: {},
create: {
id: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
name: 'Sales pipeline',
icon: '💰',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
pipelineProgressableType: 'Company',
},
});
await prisma.pipelineStage.upsert({
where: { id: 'twenty-fe256b39-3ec3-4fe3-8998-b76aa0bfb600' },
update: {},
create: {
id: 'twenty-fe256b39-3ec3-4fe3-8998-b76aa0bfb600',
name: 'New',
color: 'red',
position: 0,
type: 'open',
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
},
});
await prisma.pipelineStage.upsert({
where: { id: 'twenty-fe256b39-3ec3-4fe4-8998-b76aa0bfb600' },
update: {},
create: {
id: 'twenty-fe256b39-3ec3-4fe4-8998-b76aa0bfb600',
name: 'Screening',
color: 'purple',
position: 1,
type: 'ongoing',
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
},
});
await prisma.pipelineStage.upsert({
where: { id: 'twenty-fe256b39-3ec3-4fe5-8998-b76aa0bfb600' },
update: {},
create: {
id: 'twenty-fe256b39-3ec3-4fe5-8998-b76aa0bfb600',
name: 'Meeting',
color: 'sky',
position: 2,
type: 'ongoing',
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
},
});
await prisma.pipelineStage.upsert({
where: { id: 'twenty-fe256b39-3ec3-4fe6-8998-b76aa0bfb600' },
update: {},
create: {
id: 'twenty-fe256b39-3ec3-4fe6-8998-b76aa0bfb600',
name: 'Proposal',
color: 'turquoise',
position: 3,
type: 'ongoing',
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
},
});
await prisma.pipelineStage.upsert({
where: { id: 'twenty-fe256b39-3ec3-4fe7-8998-b76aa0bfb600' },
update: {},
create: {
id: 'twenty-fe256b39-3ec3-4fe7-8998-b76aa0bfb600',
name: 'Customer',
color: 'yellow',
position: 4,
type: 'won',
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
},
});
await prisma.pipelineProgress.upsert({
where: { id: 'twenty-fe256b39-3ec3-4fe7-8998-b76aa0bfb600' },
update: {},
create: {
id: 'twenty-fe256b39-3ec3-4fe7-8998-b76aa0bfb600',
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
pipelineStageId: 'twenty-fe256b39-3ec3-4fe3-8998-b76aa0bfb600',
companyId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfa408',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
},
});
await prisma.pipelineProgress.upsert({
where: { id: 'twenty-4a886c90-f4f2-4984-8222-882ebbb905d6' },
update: {},
create: {
id: 'twenty-4a886c90-f4f2-4984-8222-882ebbb905d6',
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
pipelineStageId: 'twenty-fe256b39-3ec3-4fe4-8998-b76aa0bfb600',
companyId: 'twenty-118995f3-5d81-46d6-bf83-f7fd33ea6102',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
},
});
await prisma.pipelineProgress.upsert({
where: { id: 'twenty-af92f3eb-d51d-4528-9b97-b8f132865b00' },
update: {},
create: {
id: 'twenty-af92f3eb-d51d-4528-9b97-b8f132865b00',
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
pipelineStageId: 'twenty-fe256b39-3ec3-4fe5-8998-b76aa0bfb600',
companyId: 'twenty-04b2e9f5-0713-40a5-8216-82802401d33e',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
},
});
await prisma.pipelineProgress.upsert({
where: { id: 'twenty-08369b1a-acdb-43d6-95f9-67ac7436941a' },
update: {},
create: {
id: 'twenty-08369b1a-acdb-43d6-95f9-67ac7436941a',
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
pipelineStageId: 'twenty-fe256b39-3ec3-4fe5-8998-b76aa0bfb600',
companyId: 'twenty-460b6fb1-ed89-413a-b31a-962986e67bb4',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
},
});
await prisma.pipeline.upsert({
where: { id: 'twenty-fe256b39-3ec3-4fe3-8997-b74aa0bfb400' },
update: {},
create: {
id: 'twenty-fe256b39-3ec3-4fe3-8997-b74aa0bfb400',
name: 'Customer support pipeline',
icon: '📔',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
pipelineProgressableType: 'Person',
},
});
await prisma.pipelineStage.upsert({
where: { id: 'twenty-fe256b39-3ec3-4fe3-8998-a76aa0bfb600' },
update: {},
create: {
id: 'twenty-fe256b39-3ec3-4fe3-8998-a76aa0bfb600',
name: 'New',
color: 'red',
position: 1,
type: 'open',
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b74aa0bfb400',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
},
});
await prisma.pipelineProgress.upsert({
where: { id: 'twenty-fe256b39-3ec3-4fe7-8998-b76aa0bfb600' },
update: {},
create: {
id: 'twenty-fe256b39-3ec3-4fe7-8998-b76aa0bfb600',
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b74aa0bfb400',
pipelineStageId: 'twenty-fe256b39-3ec3-4fe3-8998-a76aa0bfb600',
personId: 'twenty-755035db-623d-41fe-92e7-dd45b7c568e1',
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
},
});
await prisma.pipeline.upsert({
where: { id: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b75aa0bfb400' },
update: {},
create: {
id: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
name: 'Sales pipeline',
icon: '💰',
workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
},
});
await prisma.pipelineStage.upsert({
where: { id: 'twenty-dev-fe256b39-3ec3-4fe3-8998-b76aa0bfb600' },
update: {},
create: {
id: 'twenty-dev-fe256b39-3ec3-4fe3-8998-b76aa0bfb600',
name: 'New',
color: 'red',
position: 0,
type: 'open',
pipelineId: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
},
});
await prisma.pipelineStage.upsert({
where: { id: 'twenty-dev-fe256b39-3ec3-4fe4-8998-b76aa0bfb600' },
update: {},
create: {
id: 'twenty-dev-fe256b39-3ec3-4fe4-8998-b76aa0bfb600',
name: 'Screening',
color: 'purple',
position: 1,
type: 'ongoing',
pipelineId: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
},
});
await prisma.pipelineStage.upsert({
where: { id: 'twenty-dev-fe256b39-3ec3-4fe5-8998-b76aa0bfb600' },
update: {},
create: {
id: 'twenty-dev-fe256b39-3ec3-4fe5-8998-b76aa0bfb600',
name: 'Meeting',
color: 'sky',
position: 2,
type: 'ongoing',
pipelineId: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
},
});
await prisma.pipelineStage.upsert({
where: { id: 'twenty-dev-fe256b39-3ec3-4fe6-8998-b76aa0bfb600' },
update: {},
create: {
id: 'twenty-dev-fe256b39-3ec3-4fe6-8998-b76aa0bfb600',
name: 'Proposal',
color: 'turquoise',
position: 3,
type: 'ongoing',
pipelineId: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
},
});
await prisma.pipelineStage.upsert({
where: { id: 'twenty-dev-fe256b39-3ec3-4fe7-8998-b76aa0bfb600' },
update: {},
create: {
id: 'twenty-dev-fe256b39-3ec3-4fe7-8998-b76aa0bfb600',
name: 'Customer',
color: 'yellow',
position: 4,
type: 'won',
pipelineId: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
},
});
};

View File

@ -1,90 +0,0 @@
import { PrismaClient } from '@prisma/client';
export const seedUsers = async (prisma: PrismaClient) => {
await prisma.userSettings.upsert({
where: { id: 'twenty-ge256b39-3ec3-4fe3-8997-9dcb1084c109' },
update: {},
create: {
id: 'twenty-ge256b39-3ec3-4fe3-8997-9dcb1084c109',
locale: 'en',
},
});
await prisma.user.upsert({
where: { id: '20202020-a838-4fa9-b59b-96409b9a1c30' },
update: {},
create: {
id: '20202020-a838-4fa9-b59b-96409b9a1c30',
firstName: 'Tim',
lastName: 'Apple',
email: 'tim@apple.dev',
locale: 'en',
passwordHash:
'$2b$10$66d.6DuQExxnrfI9rMqOg.U1XIYpagr6Lv05uoWLYbYmtK0HDIvS6', // Applecar2025
avatarUrl: null,
defaultWorkspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
},
});
await prisma.userSettings.upsert({
where: { id: 'twenty-ge256b39-3ec3-4fe3-8997-2c4a2035a215' },
update: {},
create: {
id: 'twenty-ge256b39-3ec3-4fe3-8997-2c4a2035a215',
locale: 'en',
},
});
await prisma.user.upsert({
where: { id: '20202020-c231-45c5-b9f2-cf8b70191f6d' },
update: {},
create: {
id: '20202020-c231-45c5-b9f2-cf8b70191f6d',
firstName: 'Jony',
lastName: 'Ive',
email: 'jony.ive@apple.dev',
locale: 'en',
avatarUrl: null,
defaultWorkspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
},
});
await prisma.userSettings.upsert({
where: { id: 'twenty-ge256b39-3ec3-4fe3-8997-8e1f2097b328' },
update: {},
create: {
id: 'twenty-ge256b39-3ec3-4fe3-8997-8e1f2097b328',
locale: 'en',
},
});
await prisma.user.upsert({
where: { id: '20202020-ef2e-45df-b677-32fa06d4bd2a' },
update: {},
create: {
id: '20202020-ef2e-45df-b677-32fa06d4bd2a',
firstName: 'Phil',
lastName: 'Schiler',
email: 'phil.schiler@apple.dev',
locale: 'en',
avatarUrl: null,
defaultWorkspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
},
});
await prisma.userSettings.upsert({
where: { id: 'twenty-ge256b39-3ec3-4fe3-8997-5e2d1049c430' },
update: {},
create: {
id: 'twenty-ge256b39-3ec3-4fe3-8997-5e2d1049c430',
locale: 'en',
},
});
await prisma.user.upsert({
where: { id: 'twenty-dev-gk256b39-3ec3-4fe3-8997-b76aa0boa408' },
update: {},
create: {
id: 'twenty-dev-gk256b39-3ec3-4fe3-8997-b76aa0boa408',
firstName: 'Charles',
lastName: 'Bochet',
email: 'charles@twenty.dev',
locale: 'en',
},
});
};

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,10 @@
import { DataSource } from 'typeorm';
import { seedUsers } from 'src/database/typeorm-seeds/core/users';
import { seedWorkspaces } from 'src/database/typeorm-seeds/core/workspaces';
export const seedCoreSchema = async (workspaceDataSource: DataSource) => {
const schemaName = 'core';
await seedWorkspaces(workspaceDataSource, schemaName);
await seedUsers(workspaceDataSource, schemaName);
};

View File

@ -0,0 +1,60 @@
import { DataSource } from 'typeorm';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const tableName = 'user';
export enum SeedUserIds {
Tim = '20202020-9e3b-46d4-a556-88b9ddc2b034',
Jony = '20202020-3957-4908-9c36-2929a23f8357',
Phil = '20202020-7169-42cf-bc47-1cfef15264b8',
}
export const seedUsers = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${tableName}`, [
'id',
'firstName',
'lastName',
'email',
'passwordHash',
'defaultWorkspaceId',
])
.orIgnore()
.values([
{
id: SeedUserIds.Tim,
firstName: 'Tim',
lastName: 'Apple',
email: 'tim@apple.dev',
passwordHash:
'$2b$10$66d.6DuQExxnrfI9rMqOg.U1XIYpagr6Lv05uoWLYbYmtK0HDIvS6', // Applecar2025
defaultWorkspaceId: SeedWorkspaceId,
},
{
id: SeedUserIds.Jony,
firstName: 'Jony',
lastName: 'Ive',
email: 'jony.ive@apple.dev',
passwordHash:
'$2b$10$66d.6DuQExxnrfI9rMqOg.U1XIYpagr6Lv05uoWLYbYmtK0HDIvS6', // Applecar2025
defaultWorkspaceId: SeedWorkspaceId,
},
,
{
id: SeedUserIds.Phil,
firstName: 'Phil',
lastName: 'Schiler',
email: 'phil.schiler@apple.dev',
passwordHash:
'$2b$10$66d.6DuQExxnrfI9rMqOg.U1XIYpagr6Lv05uoWLYbYmtK0HDIvS6', // Applecar2025
defaultWorkspaceId: SeedWorkspaceId,
},
])
.execute();
};

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,33 @@
import { DataSource } from 'typeorm';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
export const SeedWorkspaceSchemaName = 'workspace_1wgvd1injqtife6y4rvfbu3h5';
const tableName = 'dataSource';
export const SeedDataSourceId = '20202020-7f63-47a9-b1b3-6c7290ca9fb1';
export const seedDataSource = async (
workspaceDataSource: DataSource,
schemaName: string,
) => {
await workspaceDataSource.query(
`CREATE SCHEMA IF NOT EXISTS ${SeedWorkspaceSchemaName}`,
);
await workspaceDataSource
.createQueryBuilder()
.insert()
.into(`${schemaName}.${tableName}`, ['id', 'schema', 'type', 'workspaceId'])
.orIgnore()
.values([
{
id: SeedDataSourceId,
schema: SeedWorkspaceSchemaName,
type: 'postgres',
workspaceId: SeedWorkspaceId,
},
])
.execute();
};

View File

@ -1,8 +1,8 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedWorkspaceId } from 'src/database/seeds/metadata';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const fieldMetadataTableName = 'fieldMetadata';

View File

@ -1,8 +1,8 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedWorkspaceId } from 'src/database/seeds/metadata';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const fieldMetadataTableName = 'fieldMetadata';

View File

@ -1,8 +1,8 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedWorkspaceId } from 'src/database/seeds/metadata';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const fieldMetadataTableName = 'fieldMetadata';

View File

@ -1,8 +1,8 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedWorkspaceId } from 'src/database/seeds/metadata';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const fieldMetadataTableName = 'fieldMetadata';

View File

@ -1,8 +1,8 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedWorkspaceId } from 'src/database/seeds/metadata';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const fieldMetadataTableName = 'fieldMetadata';

View File

@ -1,8 +1,8 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedWorkspaceId } from 'src/database/seeds/metadata';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const fieldMetadataTableName = 'fieldMetadata';

View File

@ -1,8 +1,8 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedWorkspaceId } from 'src/database/seeds/metadata';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const fieldMetadataTableName = 'fieldMetadata';
@ -17,8 +17,7 @@ export enum SeedFavoriteFieldMetadataIds {
WorkspaceMemberForeignKey = '20202020-0f4c-4b9a-9b9a-917a68161a4f',
Person = '20202020-0876-4735-8974-ff4d51aafa07',
PersonForeignKey = '20202020-0876-4735-9473-ff4d51aa4e7b',
Company = '20202020-09e1-4384-ae3e-39e7956396fe',
CompanyV2 = '20202020-09e1-4384-ae3e-39e7956396ff',
Company = '20202020-09e1-4384-ae3e-39e7956396ff',
CompanyForeignKey = '20202020-09e1-4384-ae3e-45e79563d528',
}

View File

@ -1,8 +1,8 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedWorkspaceId } from 'src/database/seeds/metadata';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const fieldMetadataTableName = 'fieldMetadata';

View File

@ -1,8 +1,8 @@
import { DataSource } from 'typeorm';
import { SeedObjectMetadataIds } from 'src/database/typeorm-seeds/metadata/object-metadata';
import { SeedWorkspaceId } from 'src/database/seeds/metadata';
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';
const fieldMetadataTableName = 'fieldMetadata';

Some files were not shown because too many files have changed in this diff Show More