Migrate view field to new data model - Part 2 (#2270)
* Migrate view field to new data model * Migrate view fields to new model
This commit is contained in:
@ -6,7 +6,6 @@ import { seedPeople } from './people';
|
||||
import { seedComments } from './comments';
|
||||
import { seedUsers } from './users';
|
||||
import { seedPipelines } from './pipelines';
|
||||
import { seedViews } from './views';
|
||||
import { seedMetadata } from './metadata';
|
||||
|
||||
const seed = async () => {
|
||||
@ -17,7 +16,6 @@ const seed = async () => {
|
||||
await seedPeople(prisma);
|
||||
await seedComments(prisma);
|
||||
await seedPipelines(prisma);
|
||||
await seedViews(prisma);
|
||||
await seedMetadata(prisma);
|
||||
await prisma.$disconnect();
|
||||
};
|
||||
|
||||
@ -19,7 +19,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
|
||||
id: 'twenty-fe256b39-3ec3-4fe3-8998-b76aa0bfb600',
|
||||
name: 'New',
|
||||
color: 'red',
|
||||
index: 0,
|
||||
position: 0,
|
||||
type: 'open',
|
||||
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
@ -33,7 +33,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
|
||||
id: 'twenty-fe256b39-3ec3-4fe4-8998-b76aa0bfb600',
|
||||
name: 'Screening',
|
||||
color: 'purple',
|
||||
index: 1,
|
||||
position: 1,
|
||||
type: 'ongoing',
|
||||
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
@ -47,7 +47,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
|
||||
id: 'twenty-fe256b39-3ec3-4fe5-8998-b76aa0bfb600',
|
||||
name: 'Meeting',
|
||||
color: 'sky',
|
||||
index: 2,
|
||||
position: 2,
|
||||
type: 'ongoing',
|
||||
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
@ -61,7 +61,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
|
||||
id: 'twenty-fe256b39-3ec3-4fe6-8998-b76aa0bfb600',
|
||||
name: 'Proposal',
|
||||
color: 'turquoise',
|
||||
index: 3,
|
||||
position: 3,
|
||||
type: 'ongoing',
|
||||
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
@ -75,7 +75,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
|
||||
id: 'twenty-fe256b39-3ec3-4fe7-8998-b76aa0bfb600',
|
||||
name: 'Customer',
|
||||
color: 'yellow',
|
||||
index: 4,
|
||||
position: 4,
|
||||
type: 'won',
|
||||
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
@ -149,7 +149,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
|
||||
id: 'twenty-fe256b39-3ec3-4fe3-8998-a76aa0bfb600',
|
||||
name: 'New',
|
||||
color: 'red',
|
||||
index: 1,
|
||||
position: 1,
|
||||
type: 'open',
|
||||
pipelineId: 'twenty-fe256b39-3ec3-4fe3-8997-b74aa0bfb400',
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
@ -186,7 +186,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
|
||||
id: 'twenty-dev-fe256b39-3ec3-4fe3-8998-b76aa0bfb600',
|
||||
name: 'New',
|
||||
color: 'red',
|
||||
index: 0,
|
||||
position: 0,
|
||||
type: 'open',
|
||||
pipelineId: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
|
||||
workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
|
||||
@ -200,7 +200,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
|
||||
id: 'twenty-dev-fe256b39-3ec3-4fe4-8998-b76aa0bfb600',
|
||||
name: 'Screening',
|
||||
color: 'purple',
|
||||
index: 1,
|
||||
position: 1,
|
||||
type: 'ongoing',
|
||||
pipelineId: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
|
||||
workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
|
||||
@ -214,7 +214,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
|
||||
id: 'twenty-dev-fe256b39-3ec3-4fe5-8998-b76aa0bfb600',
|
||||
name: 'Meeting',
|
||||
color: 'sky',
|
||||
index: 2,
|
||||
position: 2,
|
||||
type: 'ongoing',
|
||||
pipelineId: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
|
||||
workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
|
||||
@ -228,7 +228,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
|
||||
id: 'twenty-dev-fe256b39-3ec3-4fe6-8998-b76aa0bfb600',
|
||||
name: 'Proposal',
|
||||
color: 'turquoise',
|
||||
index: 3,
|
||||
position: 3,
|
||||
type: 'ongoing',
|
||||
pipelineId: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
|
||||
workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
|
||||
@ -242,7 +242,7 @@ export const seedPipelines = async (prisma: PrismaClient) => {
|
||||
id: 'twenty-dev-fe256b39-3ec3-4fe7-8998-b76aa0bfb600',
|
||||
name: 'Customer',
|
||||
color: 'yellow',
|
||||
index: 4,
|
||||
position: 4,
|
||||
type: 'won',
|
||||
pipelineId: 'twenty-dev-fe256b39-3ec3-4fe3-8997-b75aa0bfb400',
|
||||
workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
|
||||
|
||||
@ -1,201 +0,0 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
export const seedViews = async (prisma: PrismaClient) => {
|
||||
const workspaceId = 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419';
|
||||
const companyViewId = 'twenty-5e924b69-a619-41bf-bd31-a9e8551fc9d1';
|
||||
const personViewId = 'twenty-db9e6c85-c091-4fd6-88b1-c1830f5e90d1';
|
||||
const opportunitiesViewId = 'twenty-6abb47a2-7a91-4679-a538-59946f0c06a9';
|
||||
|
||||
await prisma.view.upsert({
|
||||
where: { id: companyViewId },
|
||||
update: {},
|
||||
create: {
|
||||
id: companyViewId,
|
||||
name: 'All Companies',
|
||||
objectId: 'company',
|
||||
type: 'Table',
|
||||
workspaceId,
|
||||
},
|
||||
});
|
||||
|
||||
await Promise.all(
|
||||
[
|
||||
{
|
||||
key: 'name',
|
||||
name: 'Name',
|
||||
size: 180,
|
||||
},
|
||||
{
|
||||
key: 'domainName',
|
||||
name: 'URL',
|
||||
size: 100,
|
||||
},
|
||||
{
|
||||
key: 'accountOwner',
|
||||
name: 'Account Owner',
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
key: 'createdAt',
|
||||
name: 'Creation',
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
key: 'employees',
|
||||
name: 'Employees',
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
key: 'linkedin',
|
||||
name: 'LinkedIn',
|
||||
size: 170,
|
||||
},
|
||||
{
|
||||
key: 'address',
|
||||
name: 'Address',
|
||||
size: 170,
|
||||
},
|
||||
{
|
||||
key: 'annualRecurringRevenue',
|
||||
name: 'ARR',
|
||||
size: 150,
|
||||
},
|
||||
].map((viewField, index) =>
|
||||
prisma.viewField.upsert({
|
||||
where: { viewId_key: { key: viewField.key, viewId: companyViewId } },
|
||||
update: {},
|
||||
create: {
|
||||
...viewField,
|
||||
index,
|
||||
isVisible: true,
|
||||
objectId: 'company',
|
||||
viewId: companyViewId,
|
||||
workspaceId,
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
await prisma.view.upsert({
|
||||
where: { id: personViewId },
|
||||
update: {},
|
||||
create: {
|
||||
id: personViewId,
|
||||
name: 'All People',
|
||||
objectId: 'person',
|
||||
type: 'Table',
|
||||
workspaceId,
|
||||
},
|
||||
});
|
||||
|
||||
await Promise.all(
|
||||
[
|
||||
{
|
||||
key: 'displayName',
|
||||
name: 'People',
|
||||
size: 210,
|
||||
},
|
||||
{
|
||||
key: 'email',
|
||||
name: 'Email',
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
key: 'company',
|
||||
name: 'Company',
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
key: 'phone',
|
||||
name: 'Phone',
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
key: 'createdAt',
|
||||
name: 'Creation',
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
key: 'city',
|
||||
name: 'City',
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
key: 'jobTitle',
|
||||
name: 'Job title',
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
key: 'linkedin',
|
||||
name: 'LinkedIn',
|
||||
size: 150,
|
||||
},
|
||||
{
|
||||
key: 'x',
|
||||
name: 'Twitter',
|
||||
size: 150,
|
||||
},
|
||||
].map((viewField, index) =>
|
||||
prisma.viewField.upsert({
|
||||
where: { viewId_key: { key: viewField.key, viewId: personViewId } },
|
||||
update: {},
|
||||
create: {
|
||||
...viewField,
|
||||
index,
|
||||
isVisible: true,
|
||||
objectId: 'person',
|
||||
viewId: personViewId,
|
||||
workspaceId,
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
await prisma.view.upsert({
|
||||
where: { id: opportunitiesViewId },
|
||||
update: {},
|
||||
create: {
|
||||
id: opportunitiesViewId,
|
||||
name: 'All Opportunities',
|
||||
objectId: 'company',
|
||||
type: 'Pipeline',
|
||||
workspaceId,
|
||||
},
|
||||
});
|
||||
|
||||
await Promise.all(
|
||||
[
|
||||
{
|
||||
key: 'closeDate',
|
||||
name: 'Close Date',
|
||||
},
|
||||
{
|
||||
key: 'amount',
|
||||
name: 'Amount',
|
||||
},
|
||||
{
|
||||
key: 'probability',
|
||||
name: 'Probability',
|
||||
},
|
||||
{
|
||||
key: 'pointOfContact',
|
||||
name: 'Point of Contact',
|
||||
},
|
||||
].map((viewField, index) =>
|
||||
prisma.viewField.upsert({
|
||||
where: {
|
||||
viewId_key: { key: viewField.key, viewId: opportunitiesViewId },
|
||||
},
|
||||
update: {},
|
||||
create: {
|
||||
...viewField,
|
||||
index,
|
||||
isVisible: true,
|
||||
objectId: 'company',
|
||||
viewId: opportunitiesViewId,
|
||||
workspaceId,
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user