diff --git a/server/src/database/commands/data-seed-tenant.command.ts b/server/src/database/commands/data-seed-tenant.command.ts index c206ef7c22..a877248481 100644 --- a/server/src/database/commands/data-seed-tenant.command.ts +++ b/server/src/database/commands/data-seed-tenant.command.ts @@ -11,6 +11,7 @@ import { seedViewFields } from 'src/database/typeorm-seeds/tenant/view-fields'; import { seedViews } from 'src/database/typeorm-seeds/tenant/views'; import { TypeORMService } from 'src/database/typeorm/typeorm.service'; import { seedMetadataSchema } from 'src/database/typeorm-seeds/metadata'; +import { seedWorkspaceMember } from 'src/database/typeorm-seeds/tenant/workspaceMember'; // TODO: implement dry-run @Command({ @@ -59,6 +60,7 @@ export class DataSeedTenantCommand extends CommandRunner { await seedCompanies(workspaceDataSource, dataSourceMetadata.schema); await seedViews(workspaceDataSource, dataSourceMetadata.schema); await seedViewFields(workspaceDataSource, dataSourceMetadata.schema); + await seedWorkspaceMember(workspaceDataSource, dataSourceMetadata.schema); } catch (error) { console.error(error); } diff --git a/server/src/database/seeds/comments.ts b/server/src/database/seeds/comments.ts index 287bb5f918..f51d64373c 100644 --- a/server/src/database/seeds/comments.ts +++ b/server/src/database/seeds/comments.ts @@ -9,7 +9,7 @@ export const seedComments = async (prisma: PrismaClient) => { 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: 'twenty-ge256b39-3ec3-4fe3-8997-b76aa0bfa408', + authorId: '20202020-c231-45c5-b9f2-cf8b70191f6d', }, }); @@ -34,7 +34,7 @@ export const seedComments = async (prisma: PrismaClient) => { 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: 'twenty-ge256b39-3ec3-4fe3-8997-b76aa0bfa408', + authorId: '20202020-c231-45c5-b9f2-cf8b70191f6d', }, }); @@ -47,7 +47,7 @@ export const seedComments = async (prisma: PrismaClient) => { body: 'I love it!', activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400', commentThreadId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfb400', - authorId: 'twenty-gk256b39-3ec3-4fe3-8997-b76aa0bfa408', + authorId: '20202020-ef2e-45df-b677-32fa06d4bd2a', }, }); @@ -59,10 +59,10 @@ export const seedComments = async (prisma: PrismaClient) => { workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419', title: 'Buyout Proposal', type: 'Task', - assigneeId: 'twenty-ge256b39-3ec3-4fe3-8997-b76aa0bfa408', + 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: 'twenty-ge256b39-3ec3-4fe3-8997-b76aa0bfa408', + authorId: '20202020-c231-45c5-b9f2-cf8b70191f6d', }, }); @@ -87,7 +87,7 @@ export const seedComments = async (prisma: PrismaClient) => { body: 'I really like this comment thread feature!', activityId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfc408', commentThreadId: 'twenty-fe256b39-3ec3-4fe3-8997-b76aa0bfc408', - authorId: 'twenty-ge256b39-3ec3-4fe3-8997-b76aa0bfa408', + authorId: '20202020-c231-45c5-b9f2-cf8b70191f6d', }, }); diff --git a/server/src/database/seeds/users.ts b/server/src/database/seeds/users.ts index 85280965ff..23855f6471 100644 --- a/server/src/database/seeds/users.ts +++ b/server/src/database/seeds/users.ts @@ -9,10 +9,10 @@ export const seedUsers = async (prisma: PrismaClient) => { }, }); await prisma.user.upsert({ - where: { id: 'twenty-ge256b39-3ec3-4fe3-8997-b76aa0bfc102' }, + where: { id: '20202020-a838-4fa9-b59b-96409b9a1c30' }, update: {}, create: { - id: 'twenty-ge256b39-3ec3-4fe3-8997-b76aa0bfc102', + id: '20202020-a838-4fa9-b59b-96409b9a1c30', firstName: 'Tim', lastName: 'Apple', email: 'tim@apple.dev', @@ -24,7 +24,7 @@ export const seedUsers = async (prisma: PrismaClient) => { workspaceMember: { connectOrCreate: { where: { - id: 'twenty-7ef9d213-1c25-4d02-bf35-6aeccf7ea419', + id: '20202020-0687-4c41-b707-ed1bfca972a7', }, create: { workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419', @@ -44,10 +44,10 @@ export const seedUsers = async (prisma: PrismaClient) => { }, }); await prisma.user.upsert({ - where: { id: 'twenty-ge256b39-3ec3-4fe3-8997-b76aa0bfa408' }, + where: { id: '20202020-c231-45c5-b9f2-cf8b70191f6d' }, update: {}, create: { - id: 'twenty-ge256b39-3ec3-4fe3-8997-b76aa0bfa408', + id: '20202020-c231-45c5-b9f2-cf8b70191f6d', firstName: 'Jony', lastName: 'Ive', email: 'jony.ive@apple.dev', @@ -56,7 +56,7 @@ export const seedUsers = async (prisma: PrismaClient) => { avatarUrl: null, workspaceMember: { create: { - id: 'twenty-7ef9d213-1c25-4d02-bf35-6aeccf7ea419', + id: '20202020-77d5-4cb6-b60a-f4a835a85d61', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419', settingsId: 'twenty-ge256b39-3ec3-4fe3-8997-2c4a2035a215', }, @@ -73,10 +73,10 @@ export const seedUsers = async (prisma: PrismaClient) => { }, }); await prisma.user.upsert({ - where: { id: 'twenty-gk256b39-3ec3-4fe3-8997-b76aa0bfa408' }, + where: { id: '20202020-ef2e-45df-b677-32fa06d4bd2a' }, update: {}, create: { - id: 'twenty-gk256b39-3ec3-4fe3-8997-b76aa0bfa408', + id: '20202020-ef2e-45df-b677-32fa06d4bd2a', firstName: 'Phil', lastName: 'Schiler', email: 'phil.schiler@apple.dev', @@ -85,7 +85,7 @@ export const seedUsers = async (prisma: PrismaClient) => { avatarUrl: null, workspaceMember: { create: { - id: 'twenty-7ed9d213-1c25-4d02-bf35-6aeccf7ea419', + id: '20202020-1553-45c6-a028-5a9064cce07f', workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419', settingsId: 'twenty-ge256b39-3ec3-4fe3-8997-8e1f2097b328', }, diff --git a/server/src/database/typeorm-seeds/tenant/workspaceMember.ts b/server/src/database/typeorm-seeds/tenant/workspaceMember.ts new file mode 100644 index 0000000000..f38b17c2b7 --- /dev/null +++ b/server/src/database/typeorm-seeds/tenant/workspaceMember.ts @@ -0,0 +1,64 @@ +import { DataSource } from 'typeorm'; + +const tableName = 'workspaceMember'; + +const WorkspaceMemberIds = { + Tim: '20202020-0687-4c41-b707-ed1bfca972a7', + Jony: '20202020-77d5-4cb6-b60a-f4a835a85d61', + Phil: '20202020-1553-45c6-a028-5a9064cce07f', +}; + +const WorkspaceMemberUserIds = { + Tim: '20202020-a838-4fa9-b59b-96409b9a1c30', + Jony: '20202020-c231-45c5-b9f2-cf8b70191f6d', + Phil: '20202020-ef2e-45df-b677-32fa06d4bd2a', +}; + +export const seedWorkspaceMember = async ( + workspaceDataSource: DataSource, + schemaName: string, +) => { + await workspaceDataSource + .createQueryBuilder() + .insert() + .into(`${schemaName}.${tableName}`, [ + 'id', + 'firstName', + 'lastName', + 'locale', + 'colorScheme', + 'allowImpersonation', + 'userId', + ]) + .orIgnore() + .values([ + { + id: WorkspaceMemberIds.Tim, + firstName: 'Tim', + lastName: 'Apple', + locale: 'en', + colorScheme: 'light', + allowImpersonation: true, + userId: WorkspaceMemberUserIds.Tim, + }, + { + id: WorkspaceMemberIds.Jony, + firstName: 'Jony', + lastName: 'Ive', + locale: 'en', + colorScheme: 'light', + allowImpersonation: true, + userId: WorkspaceMemberUserIds.Jony, + }, + { + id: WorkspaceMemberIds.Phil, + firstName: 'Phil', + lastName: 'Shiler', + locale: 'en', + colorScheme: 'light', + allowImpersonation: true, + userId: WorkspaceMemberUserIds.Phil, + }, + ]) + .execute(); +}; diff --git a/server/test/mock-data/user.json b/server/test/mock-data/user.json index 82807a8c9e..f6fbc0d037 100644 --- a/server/test/mock-data/user.json +++ b/server/test/mock-data/user.json @@ -1,5 +1,5 @@ { - "id": "twenty-ge256b39-3ec3-4fe3-8997-b76aa0bfc102", + "id": "20202020-a838-4fa9-b59b-96409b9a1c30", "firstName": "Tim", "lastName": "Apple", "email": "tim@apple.dev",