add index to tables
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { Cascade, Entity, ManyToOne, OptionalProps, Property } from '@mikro-orm/core';
|
||||
import { Cascade, Entity, ManyToOne, OptionalProps, Property, Index } from '@mikro-orm/core';
|
||||
import { BaseEntity } from '../../../common/entities/base.entity';
|
||||
import { Role } from 'src/modules/roles/entities/role.entity';
|
||||
|
||||
@Entity({ tableName: 'admins' })
|
||||
@Index({ properties: ['phone'] })
|
||||
export class Admin extends BaseEntity {
|
||||
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
ManyToOne,
|
||||
Property,
|
||||
OptionalProps,
|
||||
Index,
|
||||
} from '@mikro-orm/core';
|
||||
import { User } from "../../user/entities/user.entity";
|
||||
import { Admin } from 'src/modules/admin/entities/admin.entity';
|
||||
@@ -10,10 +11,10 @@ import { AttachmentType } from '../interfaces/chat';
|
||||
import { BaseEntity } from 'src/common/entities/base.entity';
|
||||
|
||||
@Entity()
|
||||
@Index({ properties: ['user'] })
|
||||
export class Chat extends BaseEntity {
|
||||
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
||||
|
||||
|
||||
@Property({ type: 'text' })
|
||||
content: string;
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { Entity, Property, ManyToOne, PrimaryKey, Unique, OptionalProps } from '@mikro-orm/core';
|
||||
import { Entity, Property, ManyToOne, PrimaryKey, Unique, OptionalProps, Index } from '@mikro-orm/core';
|
||||
import { BaseEntity } from '../../../common/entities/base.entity';
|
||||
import { Field } from './field.entity';
|
||||
|
||||
@Entity({ tableName: 'field_option' })
|
||||
@Index({ properties: ['field'] })
|
||||
export class FieldOption extends BaseEntity {
|
||||
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Collection, Entity, Enum, ManyToOne, OneToMany, OptionalProps, PrimaryKey, Property } from '@mikro-orm/core';
|
||||
import { Collection, Entity, Enum, Index, ManyToOne, OneToMany, OptionalProps, PrimaryKey, Property } from '@mikro-orm/core';
|
||||
import { FieldOption } from './field-option.entity';
|
||||
import { EntityType, FieldType } from '../interface/print';
|
||||
import { BaseEntity } from 'src/common/entities/base.entity';
|
||||
|
||||
|
||||
@Entity({ tableName: 'field' })
|
||||
@Index({ properties: ['entityId'] })
|
||||
export class Field extends BaseEntity {
|
||||
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Collection, Entity, ManyToOne, OptionalProps, Property, OneToMany, Opt } from '@mikro-orm/core';
|
||||
import { Collection, Entity, ManyToOne, OptionalProps, Property, OneToMany, Opt, Index } from '@mikro-orm/core';
|
||||
import { Product } from 'src/modules/product/entities/product.entity';
|
||||
import { BaseEntity } from 'src/common/entities/base.entity';
|
||||
import { Invoice } from './invoice.entity';
|
||||
@@ -6,6 +6,7 @@ import { Order } from 'src/modules/order/entities/order.entity';
|
||||
|
||||
|
||||
@Entity({ tableName: 'invoice_items' })
|
||||
@Index({ properties: ['invoice'] })
|
||||
export class InvoiceItem extends BaseEntity {
|
||||
[OptionalProps]?: 'createdAt' | 'deletedAt' | 'discount' | 'description' | 'confirmedAt';
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Entity, Property, ManyToOne, Enum, PrimaryKey, OptionalProps } from '@mikro-orm/core';
|
||||
import { Entity, Property, ManyToOne, Enum, Index, OptionalProps } from '@mikro-orm/core';
|
||||
import { BaseEntity } from '../../../common/entities/base.entity';
|
||||
import { User } from '../../user/entities/user.entity';
|
||||
import { NotifTitle } from '../interfaces/notification.interface';
|
||||
import { Admin } from 'src/modules/admin/entities/admin.entity';
|
||||
|
||||
@Entity({ tableName: 'notifications' })
|
||||
@Index({ properties: ['user'] })
|
||||
export class Notification extends BaseEntity {
|
||||
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@ import { OrderPrint } from './print.entity';
|
||||
|
||||
@Entity({ tableName: 'orders' })
|
||||
@Index({ properties: ['user'] })
|
||||
@Index({ properties: ['designer'] })
|
||||
@Index({ properties: ['status'] })
|
||||
export class Order extends BaseEntity {
|
||||
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Entity, ManyToOne, OptionalProps, Property } from '@mikro-orm/core';
|
||||
import { Entity, Index, ManyToOne, OptionalProps, Property } from '@mikro-orm/core';
|
||||
import { Product } from 'src/modules/product/entities/product.entity';
|
||||
import { BaseEntity } from 'src/common/entities/base.entity';
|
||||
import { Request } from './request.entity';
|
||||
import { IAttachment, IField } from '../interface/request.interface';
|
||||
|
||||
@Entity({ tableName: 'request_items' })
|
||||
@Index({ properties: ['request'] })
|
||||
export class RequestItem extends BaseEntity {
|
||||
[OptionalProps]?: 'createdAt' | 'deletedAt';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Entity, Property, Unique, ManyToMany, Collection, PrimaryKey, Enum, OptionalProps } from '@mikro-orm/core';
|
||||
import { Entity, Property, Unique, ManyToMany, Collection, PrimaryKey, Enum, OptionalProps, Index } from '@mikro-orm/core';
|
||||
import { BaseEntity } from '../../../common/entities/base.entity';
|
||||
import { Role } from './role.entity';
|
||||
import { PermissionEnum } from 'src/common/enums/permission.enum';
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { Entity, ManyToOne } from '@mikro-orm/core';
|
||||
import { Entity, Index, ManyToOne } from '@mikro-orm/core';
|
||||
import { Role } from './role.entity';
|
||||
import { Permission } from './permission.entity';
|
||||
|
||||
@Entity({ tableName: 'role_permissions' })
|
||||
@Index({ properties: ['role'] })
|
||||
export class RolePermission {
|
||||
// دو ManyToOne دقیقاً؛ هر کدام میتونن primary: true باشند برای composite PK
|
||||
@ManyToOne(() => Role, { primary: true })
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Collection, Entity, Enum, ManyToOne, OneToMany, OptionalProps, Property } from '@mikro-orm/core';
|
||||
import { Collection, Entity, Enum, Index, ManyToOne, OneToMany, OptionalProps, Property } from '@mikro-orm/core';
|
||||
import { BaseEntity } from 'src/common/entities/base.entity';
|
||||
import { TicketStatusEnum } from '../enum/status.enum';
|
||||
import { IAttachment } from 'src/modules/order/interface/order.interface';
|
||||
@@ -6,6 +6,7 @@ import { Admin } from 'src/modules/admin/entities/admin.entity';
|
||||
import { User } from 'src/modules/user/entities/user.entity';
|
||||
|
||||
@Entity({ tableName: 'tickets' })
|
||||
@Index({ properties: ['user'] })
|
||||
export class Ticket extends BaseEntity {
|
||||
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import { Criticism } from '../../criticisms/entities/criticism.entity';
|
||||
|
||||
|
||||
@Entity({ tableName: 'users' })
|
||||
@Index({properties:['phone']})
|
||||
export class User extends BaseEntity {
|
||||
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user