Files
twenty/packages/twenty-server/src/engine/workspace-manager/standard-objects-prefill-data/company.ts
gitstart-app[bot] fa241fa4e9 Handle migration of Phone field to Phones field (#7128)
This PR was created by [GitStart](https://gitstart.com/) to address the
requirements from this ticket:
[TWNTY-6260](https://clients.gitstart.com/twenty/5449/tickets/TWNTY-6260).
This ticket was imported from:
[TWNTY-6260](https://github.com/twentyhq/twenty/issues/6260)

 --- 

### Description

This is the second PR on TWNTY-6260 which handles data migration of
Phone field to Phones field.\
\
How to Test?\
 Follow the below steps:

- On the main branch, 
- go to
`packages/twenty-server/src/database/typeorm-seeds/workspace/people.ts`
and change any person's phone number to a string with characters for
example: "test invalid phone", and then reset the DB.
  - reset database using `npx nx database:reset twenty-server`
- This is to make sure that invalid numbers will be handled properly. We
should use the invalid value itself to avoid removing data and see how
the behavior is on the front end. should be the same as in the main, the
display shows the invalid value, but the input is empty when you click,
and then you can update.
- Checkout to `TWNTY-6260-phone-migration` branch
- Rebuild typescript using `npx nx build twenty-server`
- Run command `yarn command:prod upgrade-0.32` to do migration
- Run both backend and frontend to see the migrated field

### Demo

- **Loom Video:**\

<https://www.loom.com/share/4b9bcb423cee447d8ad09852a83b27da?sid=ed74ecaa-0339-4575-acdc-a863e95e94fd>

### Refs

#6260

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: Marie Stoppa <marie.stoppa@essec.edu>
Co-authored-by: Weiko <corentin@twenty.com>
2024-09-24 16:31:30 +02:00

118 lines
3.6 KiB
TypeScript

import { EntityManager } from 'typeorm';
export const AIRBNB_ID = 'c776ee49-f608-4a77-8cc8-6fe96ae1e43f';
export const QONTO_ID = 'f45ee421-8a3e-4aa5-a1cf-7207cc6754e1';
export const STRIPE_ID = '1f70157c-4ea5-4d81-bc49-e1401abfbb94';
export const FIGMA_ID = '9d5bcf43-7d38-4e88-82cb-d6d4ce638bf0';
export const NOTION_ID = '06290608-8bf0-4806-99ae-a715a6a93fad';
export const companyPrefillData = async (
entityManager: EntityManager,
schemaName: string,
) => {
await entityManager
.createQueryBuilder()
.insert()
.into(`${schemaName}.company`, [
'id',
'name',
'domainNamePrimaryLinkUrl',
'addressAddressStreet1',
'addressAddressStreet2',
'addressAddressCity',
'addressAddressState',
'addressAddressPostcode',
'addressAddressCountry',
'employees',
'position',
'createdBySource',
'createdByWorkspaceMemberId',
'createdByName',
])
.orIgnore()
.values([
{
id: AIRBNB_ID,
name: 'Airbnb',
domainNamePrimaryLinkUrl: 'https://airbnb.com',
addressAddressStreet1: '888 Brannan St',
addressAddressStreet2: null,
addressAddressCity: 'San Francisco',
addressAddressState: 'CA',
addressAddressPostcode: '94103',
addressAddressCountry: 'United States',
employees: 5000,
position: 1,
createdBySource: 'MANUAL',
createdByWorkspaceMemberId: null,
createdByName: 'System',
},
{
id: QONTO_ID,
name: 'Qonto',
domainNamePrimaryLinkUrl: 'https://qonto.com',
addressAddressStreet1: '18 rue de navarrin',
addressAddressStreet2: null,
addressAddressCity: 'Paris',
addressAddressState: null,
addressAddressPostcode: '75009',
addressAddressCountry: 'France',
employees: 800,
position: 2,
createdBySource: 'MANUAL',
createdByWorkspaceMemberId: null,
createdByName: 'System',
},
{
id: STRIPE_ID,
name: 'Stripe',
domainNamePrimaryLinkUrl: 'https://stripe.com',
addressAddressStreet1: 'Eutaw Street',
addressAddressStreet2: null,
addressAddressCity: 'Dublin',
addressAddressState: null,
addressAddressPostcode: null,
addressAddressCountry: 'Ireland',
employees: 8000,
position: 3,
createdBySource: 'MANUAL',
createdByWorkspaceMemberId: null,
createdByName: 'System',
},
{
id: FIGMA_ID,
name: 'Figma',
domainNamePrimaryLinkUrl: 'https://figma.com',
addressAddressStreet1: '760 Market St',
addressAddressStreet2: 'Floor 10',
addressAddressCity: 'San Francisco',
addressAddressState: null,
addressAddressPostcode: '94102',
addressAddressCountry: 'United States',
employees: 800,
position: 4,
createdBySource: 'MANUAL',
createdByWorkspaceMemberId: null,
createdByName: 'System',
},
{
id: NOTION_ID,
name: 'Notion',
domainNamePrimaryLinkUrl: 'https://notion.com',
addressAddressStreet1: '2300 Harrison St',
addressAddressStreet2: null,
addressAddressCity: 'San Francisco',
addressAddressState: 'CA',
addressAddressPostcode: '94110',
addressAddressCountry: 'United States',
employees: 400,
position: 5,
createdBySource: 'MANUAL',
createdByWorkspaceMemberId: null,
createdByName: 'System',
},
])
.returning('*')
.execute();
};