mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 00:48:25 +00:00
Added indexes to the components table on columns name, type, and page_id to optimize query performance.
This commit is contained in:
parent
af64dc91df
commit
683fe331e4
2 changed files with 16 additions and 3 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { MigrationInterface, QueryRunner, Table, TableForeignKey } from 'typeorm';
|
||||
import { MigrationInterface, QueryRunner, Table, TableForeignKey, TableIndex } from 'typeorm';
|
||||
|
||||
export class CreateComponentTable1691006952074 implements MigrationInterface {
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
|
|
@ -46,7 +46,6 @@ export class CreateComponentTable1691006952074 implements MigrationInterface {
|
|||
})
|
||||
);
|
||||
|
||||
// Add foreign key to relate Component with Page
|
||||
await queryRunner.createForeignKey(
|
||||
'components',
|
||||
new TableForeignKey({
|
||||
|
|
@ -56,9 +55,22 @@ export class CreateComponentTable1691006952074 implements MigrationInterface {
|
|||
onDelete: 'CASCADE',
|
||||
})
|
||||
);
|
||||
|
||||
await queryRunner.createIndex('components', new TableIndex({ columnNames: ['name'] }));
|
||||
await queryRunner.createIndex('components', new TableIndex({ columnNames: ['type'] }));
|
||||
await queryRunner.createIndex('components', new TableIndex({ columnNames: ['page_id'] }));
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
// Drop indexes
|
||||
await queryRunner.dropIndex('components', 'IDX_COMPONENT_NAME');
|
||||
await queryRunner.dropIndex('components', 'IDX_COMPONENT_TYPE');
|
||||
await queryRunner.dropIndex('components', 'IDX_COMPONENT_PAGE');
|
||||
|
||||
// Drop foreign key
|
||||
await queryRunner.dropForeignKey('components', 'FK_COMPONENT_PAGE');
|
||||
|
||||
// Drop table
|
||||
await queryRunner.dropTable('components');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, OneToMany, JoinColumn } from 'typeorm';
|
||||
import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, OneToMany, JoinColumn, Index } from 'typeorm';
|
||||
import { Page } from './page.entity';
|
||||
import { Layout } from './layout.entity';
|
||||
|
||||
@Entity({ name: 'components' })
|
||||
@Index('idx_component_page_id', ['pageId'])
|
||||
export class Component {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
|
|
|||
Loading…
Reference in a new issue