Performance improvement to dev xp (#9294)
The DX is not great when you need to do a lot of database resets/command. Should we disable Typescript validation to speed things up? With this and caching database:reset takes 1min instead of 2 on my machine. See also: https://github.com/typeorm/typeorm/issues/4136 And #9291 / #9293 --------- Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
@ -4,7 +4,7 @@
|
||||
"sourceRoot": "src",
|
||||
"compilerOptions": {
|
||||
"builder": "swc",
|
||||
"typeCheck": true,
|
||||
"typeCheck": false,
|
||||
"assets": [
|
||||
{
|
||||
"include": "**/serverless/drivers/constants/base-typescript-project/**",
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
"targets": {
|
||||
"build": {
|
||||
"executor": "nx:run-commands",
|
||||
"cache": true,
|
||||
"options": {
|
||||
"cwd": "packages/twenty-server",
|
||||
"commands": ["rimraf dist", "nest build --path ./tsconfig.build.json"]
|
||||
@ -99,7 +100,7 @@
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"cwd": "packages/twenty-server",
|
||||
"command": "ts-node ../../node_modules/typeorm/cli.js"
|
||||
"command": "ts-node --transpile-only -P tsconfig.json ../../node_modules/typeorm/cli.js"
|
||||
}
|
||||
},
|
||||
"ts-node": {
|
||||
@ -117,6 +118,13 @@
|
||||
"command": "ts-node"
|
||||
}
|
||||
},
|
||||
"ts-node-no-deps-transpile-only": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"cwd": "packages/twenty-server",
|
||||
"command": "ts-node --transpile-only"
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"options": {
|
||||
"lintFilePatterns": ["{projectRoot}/src/**/*.{ts,json}"]
|
||||
@ -149,8 +157,7 @@
|
||||
"commands": [
|
||||
"nx typeorm -- migration:run -d src/database/typeorm/metadata/metadata.datasource",
|
||||
"nx typeorm -- migration:run -d src/database/typeorm/core/core.datasource"
|
||||
],
|
||||
"parallel": false
|
||||
]
|
||||
}
|
||||
},
|
||||
"database:migrate:revert": {
|
||||
@ -161,8 +168,7 @@
|
||||
"commands": [
|
||||
"nx typeorm -- migration:revert -d src/database/typeorm/metadata/metadata.datasource",
|
||||
"nx typeorm -- migration:revert -d src/database/typeorm/core/core.datasource"
|
||||
],
|
||||
"parallel": false
|
||||
]
|
||||
}
|
||||
},
|
||||
"generate:integration-test": {
|
||||
@ -182,8 +188,8 @@
|
||||
"no-seed": {
|
||||
"cwd": "packages/twenty-server",
|
||||
"commands": [
|
||||
"nx ts-node-no-deps -- ./scripts/truncate-db.ts",
|
||||
"nx ts-node-no-deps -- ./scripts/setup-db.ts",
|
||||
"nx ts-node-no-deps-transpile-only -- ./scripts/truncate-db.ts",
|
||||
"nx ts-node-no-deps-transpile-only -- ./scripts/setup-db.ts",
|
||||
"nx database:migrate",
|
||||
"nx command-no-deps -- cache:flush"
|
||||
],
|
||||
@ -192,8 +198,8 @@
|
||||
"seed": {
|
||||
"cwd": "packages/twenty-server",
|
||||
"commands": [
|
||||
"nx ts-node-no-deps -- ./scripts/truncate-db.ts",
|
||||
"nx ts-node-no-deps -- ./scripts/setup-db.ts",
|
||||
"nx ts-node-no-deps-transpile-only -- ./scripts/truncate-db.ts",
|
||||
"nx ts-node-no-deps-transpile-only -- ./scripts/setup-db.ts",
|
||||
"nx database:migrate",
|
||||
"nx command-no-deps -- cache:flush",
|
||||
"nx command-no-deps -- workspace:seed:dev"
|
||||
|
||||
@ -30,6 +30,11 @@ rawDataSource
|
||||
'create extension "uuid-ossp"',
|
||||
);
|
||||
|
||||
// We paused the work on FDW
|
||||
if (process.env.IS_FDW_ENABLED !== 'true') {
|
||||
return;
|
||||
}
|
||||
|
||||
await performQuery(
|
||||
'CREATE EXTENSION IF NOT EXISTS "postgres_fdw"',
|
||||
'create extension "postgres_fdw"',
|
||||
|
||||
@ -8,32 +8,30 @@ async function dropSchemasSequentially() {
|
||||
try {
|
||||
await rawDataSource.initialize();
|
||||
|
||||
// Fetch all schemas
|
||||
// Fetch all schemas excluding the ones we want to keep
|
||||
const schemas = await performQuery(
|
||||
`
|
||||
SELECT n.nspname AS "schema_name"
|
||||
FROM pg_catalog.pg_namespace n
|
||||
WHERE n.nspname !~ '^pg_' AND n.nspname <> 'information_schema'
|
||||
FROM pg_catalog.pg_namespace n
|
||||
WHERE n.nspname !~ '^pg_'
|
||||
AND n.nspname <> 'information_schema'
|
||||
AND n.nspname NOT IN ('metric_helpers', 'user_management', 'public')
|
||||
`,
|
||||
'Fetching schemas...',
|
||||
);
|
||||
|
||||
// Iterate over each schema and drop it
|
||||
// This is to avoid dropping all schemas at once, which would cause an out of shared memory error
|
||||
for (const schema of schemas) {
|
||||
if (
|
||||
schema.schema_name === 'metric_helpers' ||
|
||||
schema.schema_name === 'user_management' ||
|
||||
schema.schema_name === 'public'
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
const batchSize = 10;
|
||||
|
||||
await performQuery(
|
||||
`
|
||||
DROP SCHEMA IF EXISTS "${schema.schema_name}" CASCADE;
|
||||
`,
|
||||
`Dropping schema ${schema.schema_name}...`,
|
||||
for (let i = 0; i < schemas.length; i += batchSize) {
|
||||
const batch = schemas.slice(i, i + batchSize);
|
||||
|
||||
await Promise.all(
|
||||
batch.map((schema) =>
|
||||
performQuery(
|
||||
`DROP SCHEMA IF EXISTS "${schema.schema_name}" CASCADE;`,
|
||||
`Dropping schema ${schema.schema_name}...`,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -17,4 +17,6 @@ export enum FeatureFlagKey {
|
||||
IsAggregateQueryEnabled = 'IS_AGGREGATE_QUERY_ENABLED',
|
||||
IsViewGroupsEnabled = 'IS_VIEW_GROUPS_ENABLED',
|
||||
IsPageHeaderV2Enabled = 'IS_PAGE_HEADER_V2_ENABLED',
|
||||
IsCrmMigrationEnabled = 'IS_CRM_MIGRATION_ENABLED',
|
||||
IsJsonFilterEnabled = 'IS_JSON_FILTER_ENABLED',
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Field, ObjectType } from '@nestjs/graphql';
|
||||
import { Field, ObjectType, registerEnumType } from '@nestjs/graphql';
|
||||
|
||||
import { IDField } from '@ptc-org/nestjs-query-graphql';
|
||||
import {
|
||||
@ -24,7 +24,7 @@ export class FeatureFlagEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Field(() => String)
|
||||
@Field(() => FeatureFlagKey)
|
||||
@Column({ nullable: false, type: 'text' })
|
||||
key: FeatureFlagKey;
|
||||
|
||||
@ -47,3 +47,7 @@ export class FeatureFlagEntity {
|
||||
@UpdateDateColumn({ type: 'timestamptz' })
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
registerEnumType(FeatureFlagKey, {
|
||||
name: 'FeatureFlagKey',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user