Skip to content

Commit

Permalink
Rename typeorm metadata table (twentyhq#7473)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijreilly authored Oct 7, 2024
1 parent fbb5b3d commit 491fe80
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const typeORMCoreModuleOptions: TypeOrmModuleOptions = {
synchronize: false,
migrationsRun: false,
migrationsTableName: '_typeorm_migrations',
metadataTableName: '_typeorm_generated_columns_and_materialized_views',
migrations: [
`${isJest ? '' : 'dist/'}src/database/typeorm/core/migrations/*{.ts,.js}`,
],
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class AddTypeormGeneratedColumns1728314605995
implements MigrationInterface
{
name = 'AddTypeormGeneratedColumnsAndMaterializedViews1728314605995';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
CREATE TABLE "core"."_typeorm_generated_columns_and_materialized_views" (
"type" character varying NOT NULL,
"database" character varying,
"schema" character varying,
"table" character varying,
"name" character varying,
"value" text
)
`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`DROP TABLE "core"."_typeorm_generated_columns_and_materialized_views"`,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common';

import { DataSource } from 'typeorm';

import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
import { DataSourceEntity } from 'src/engine/metadata-modules/data-source/data-source.entity';
import { AppToken } from 'src/engine/core-modules/app-token/app-token.entity';
import { BillingSubscriptionItem } from 'src/engine/core-modules/billing/entities/billing-subscription-item.entity';
import { BillingSubscription } from 'src/engine/core-modules/billing/entities/billing-subscription.entity';
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
import { FeatureFlagEntity } from 'src/engine/core-modules/feature-flag/feature-flag.entity';
import { KeyValuePair } from 'src/engine/core-modules/key-value-pair/key-value-pair.entity';
import { PostgresCredentials } from 'src/engine/core-modules/postgres-credentials/postgres-credentials.entity';
import { UserWorkspace } from 'src/engine/core-modules/user-workspace/user-workspace.entity';
import { User } from 'src/engine/core-modules/user/user.entity';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { DataSourceEntity } from 'src/engine/metadata-modules/data-source/data-source.entity';

@Injectable()
export class TypeORMService implements OnModuleInit, OnModuleDestroy {
Expand All @@ -37,6 +37,7 @@ export class TypeORMService implements OnModuleInit, OnModuleDestroy {
BillingSubscriptionItem,
PostgresCredentials,
],
metadataTableName: '_typeorm_generated_columns_and_materialized_views',
ssl: environmentService.get('PG_SSL_ALLOW_SELF_SIGNED')
? {
rejectUnauthorized: false,
Expand Down

0 comments on commit 491fe80

Please sign in to comment.