[WIP] Whole FE migrated (#2517)
* Wip * WIP * Removed concole log * Add relations to workspace init (#2511) * Add relations to workspace init * remove logs * update prefill * add missing isSystem * comment relation fields * Migrate v2 core models to graphql schema (#2509) * migrate v2 core models to graphql schema * Migrate to new workspace member schema * Continue work * migrated-main * Finished accountOwner nested field integration on companies * Introduce bug * Fix --------- Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com> Co-authored-by: Weiko <corentin@twenty.com>
This commit is contained in:
@ -0,0 +1,5 @@
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "workspace_members" DROP CONSTRAINT "workspace_members_userId_fkey";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "defaultWorkspaceId" TEXT;
|
||||
@ -0,0 +1,20 @@
|
||||
/*
|
||||
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;
|
||||
@ -0,0 +1,11 @@
|
||||
/*
|
||||
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";
|
||||
@ -102,18 +102,15 @@ model User {
|
||||
/// @Validator.IsOptional()
|
||||
canImpersonate Boolean @default(false)
|
||||
|
||||
/// @TypeGraphQL.omit(input: true)
|
||||
workspaceMember WorkspaceMember?
|
||||
companies Company[]
|
||||
companies Company[]
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
refreshTokens RefreshToken[]
|
||||
comments Comment[]
|
||||
refreshTokens RefreshToken[]
|
||||
comments Comment[]
|
||||
defaultWorkspaceId String?
|
||||
|
||||
authoredActivities Activity[] @relation(name: "authoredActivities")
|
||||
assignedActivities Activity[] @relation(name: "assignedActivities")
|
||||
authoredAttachments Attachment[] @relation(name: "authoredAttachments")
|
||||
settings UserSettings @relation(fields: [settingsId], references: [id])
|
||||
settingsId String @unique
|
||||
|
||||
/// @TypeGraphQL.omit(input: true, output: true)
|
||||
deletedAt DateTime?
|
||||
@ -138,7 +135,6 @@ model UserSettings {
|
||||
/// @Validator.IsString()
|
||||
locale String
|
||||
|
||||
user User?
|
||||
WorkspaceMember WorkspaceMember[]
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
@ -195,7 +191,6 @@ model WorkspaceMember {
|
||||
/// @Validator.IsOptional()
|
||||
allowImpersonation Boolean @default(true)
|
||||
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
userId String @unique
|
||||
/// @TypeGraphQL.omit(input: true, output: false)
|
||||
workspace Workspace @relation(fields: [workspaceId], references: [id])
|
||||
|
||||
@ -19,19 +19,8 @@ export const seedUsers = async (prisma: PrismaClient) => {
|
||||
locale: 'en',
|
||||
passwordHash:
|
||||
'$2b$10$66d.6DuQExxnrfI9rMqOg.U1XIYpagr6Lv05uoWLYbYmtK0HDIvS6', // Applecar2025
|
||||
settingsId: 'twenty-ge256b39-3ec3-4fe3-8997-9dcb1084c109',
|
||||
avatarUrl: null,
|
||||
workspaceMember: {
|
||||
connectOrCreate: {
|
||||
where: {
|
||||
id: '20202020-0687-4c41-b707-ed1bfca972a7',
|
||||
},
|
||||
create: {
|
||||
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
|
||||
settingsId: 'twenty-ge256b39-3ec3-4fe3-8997-9dcb1084c109',
|
||||
},
|
||||
},
|
||||
},
|
||||
defaultWorkspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
|
||||
},
|
||||
});
|
||||
|
||||
@ -52,15 +41,8 @@ export const seedUsers = async (prisma: PrismaClient) => {
|
||||
lastName: 'Ive',
|
||||
email: 'jony.ive@apple.dev',
|
||||
locale: 'en',
|
||||
settingsId: 'twenty-ge256b39-3ec3-4fe3-8997-2c4a2035a215',
|
||||
avatarUrl: null,
|
||||
workspaceMember: {
|
||||
create: {
|
||||
id: '20202020-77d5-4cb6-b60a-f4a835a85d61',
|
||||
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
|
||||
settingsId: 'twenty-ge256b39-3ec3-4fe3-8997-2c4a2035a215',
|
||||
},
|
||||
},
|
||||
defaultWorkspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
|
||||
},
|
||||
});
|
||||
|
||||
@ -81,15 +63,8 @@ export const seedUsers = async (prisma: PrismaClient) => {
|
||||
lastName: 'Schiler',
|
||||
email: 'phil.schiler@apple.dev',
|
||||
locale: 'en',
|
||||
settingsId: 'twenty-ge256b39-3ec3-4fe3-8997-8e1f2097b328',
|
||||
avatarUrl: null,
|
||||
workspaceMember: {
|
||||
create: {
|
||||
id: '20202020-1553-45c6-a028-5a9064cce07f',
|
||||
workspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
|
||||
settingsId: 'twenty-ge256b39-3ec3-4fe3-8997-8e1f2097b328',
|
||||
},
|
||||
},
|
||||
defaultWorkspaceId: '20202020-1c25-4d02-bf25-6aeccf7ea419',
|
||||
},
|
||||
});
|
||||
|
||||
@ -110,14 +85,6 @@ export const seedUsers = async (prisma: PrismaClient) => {
|
||||
lastName: 'Bochet',
|
||||
email: 'charles@twenty.dev',
|
||||
locale: 'en',
|
||||
settingsId: 'twenty-ge256b39-3ec3-4fe3-8997-5e2d1049c430',
|
||||
workspaceMember: {
|
||||
create: {
|
||||
id: 'twenty-dev-7ed9d213-1c25-4d02-bf35-6aeccf7oa419',
|
||||
workspaceId: 'twenty-dev-7ed9d212-1c25-4d02-bf25-6aeccf7ea420',
|
||||
settingsId: 'twenty-ge256b39-3ec3-4fe3-8997-5e2d1049c430',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@ -8,6 +8,7 @@ const fieldMetadataTableName = 'fieldMetadata';
|
||||
export enum SeedWorkspaceMemberFieldMetadataIds {
|
||||
FirstName = '20202020-1fa8-4d38-9fa4-0cf696909298',
|
||||
LastName = '20202020-8c37-4163-ba06-1dada334ce3e',
|
||||
AvatarUrl = '20202020-7ba6-40d5-934b-17146183a212',
|
||||
Locale = '20202020-10f6-4df9-8d6f-a760b65bd800',
|
||||
ColorScheme = '20202020-83f2-4c5f-96b0-0c51ecc160e3',
|
||||
AllowImpersonation = '20202020-bb19-44a1-8156-8866f87a5f42',
|
||||
@ -77,6 +78,22 @@ export const seedWorkspaceMemberFieldMetadata = async (
|
||||
icon: 'IconCircleUser',
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
id: SeedWorkspaceMemberFieldMetadataIds.AvatarUrl,
|
||||
objectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
|
||||
isCustom: false,
|
||||
workspaceId: SeedWorkspaceId,
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'avatarUrl',
|
||||
label: 'Avatar Url',
|
||||
targetColumnMap: {
|
||||
value: 'avatarUrl',
|
||||
},
|
||||
description: 'Workspace member avatar',
|
||||
icon: 'IconFileUpload',
|
||||
isNullable: true,
|
||||
},
|
||||
{
|
||||
id: SeedWorkspaceMemberFieldMetadataIds.UserId,
|
||||
objectMetadataId: SeedObjectMetadataIds.WorkspaceMember,
|
||||
@ -123,7 +140,7 @@ export const seedWorkspaceMemberFieldMetadata = async (
|
||||
},
|
||||
description: 'Preferred color scheme',
|
||||
icon: 'IconColorSwatch',
|
||||
isNullable: false,
|
||||
isNullable: true,
|
||||
},
|
||||
{
|
||||
id: SeedWorkspaceMemberFieldMetadataIds.Locale,
|
||||
|
||||
@ -37,7 +37,7 @@ export const seedWorkspaceMember = async (
|
||||
firstName: 'Tim',
|
||||
lastName: 'Apple',
|
||||
locale: 'en',
|
||||
colorScheme: 'light',
|
||||
colorScheme: 'Light',
|
||||
allowImpersonation: true,
|
||||
userId: WorkspaceMemberUserIds.Tim,
|
||||
},
|
||||
@ -46,7 +46,7 @@ export const seedWorkspaceMember = async (
|
||||
firstName: 'Jony',
|
||||
lastName: 'Ive',
|
||||
locale: 'en',
|
||||
colorScheme: 'light',
|
||||
colorScheme: 'Light',
|
||||
allowImpersonation: true,
|
||||
userId: WorkspaceMemberUserIds.Jony,
|
||||
},
|
||||
@ -55,9 +55,9 @@ export const seedWorkspaceMember = async (
|
||||
firstName: 'Phil',
|
||||
lastName: 'Shiler',
|
||||
locale: 'en',
|
||||
colorScheme: 'light',
|
||||
colorScheme: 'Light',
|
||||
allowImpersonation: true,
|
||||
userId: WorkspaceMemberUserIds.Phil,
|
||||
userId: WorkspaceMemberUserIds.Tim,
|
||||
},
|
||||
])
|
||||
.execute();
|
||||
|
||||
Reference in New Issue
Block a user