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 { BaseEntity } from '../../../common/entities/base.entity';
|
||||||
import { Role } from 'src/modules/roles/entities/role.entity';
|
import { Role } from 'src/modules/roles/entities/role.entity';
|
||||||
|
|
||||||
@Entity({ tableName: 'admins' })
|
@Entity({ tableName: 'admins' })
|
||||||
|
@Index({ properties: ['phone'] })
|
||||||
export class Admin extends BaseEntity {
|
export class Admin extends BaseEntity {
|
||||||
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
ManyToOne,
|
ManyToOne,
|
||||||
Property,
|
Property,
|
||||||
OptionalProps,
|
OptionalProps,
|
||||||
|
Index,
|
||||||
} from '@mikro-orm/core';
|
} from '@mikro-orm/core';
|
||||||
import { User } from "../../user/entities/user.entity";
|
import { User } from "../../user/entities/user.entity";
|
||||||
import { Admin } from 'src/modules/admin/entities/admin.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';
|
import { BaseEntity } from 'src/common/entities/base.entity';
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
|
@Index({ properties: ['user'] })
|
||||||
export class Chat extends BaseEntity {
|
export class Chat extends BaseEntity {
|
||||||
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
||||||
|
|
||||||
|
|
||||||
@Property({ type: 'text' })
|
@Property({ type: 'text' })
|
||||||
content: string;
|
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 { BaseEntity } from '../../../common/entities/base.entity';
|
||||||
import { Field } from './field.entity';
|
import { Field } from './field.entity';
|
||||||
|
|
||||||
@Entity({ tableName: 'field_option' })
|
@Entity({ tableName: 'field_option' })
|
||||||
|
@Index({ properties: ['field'] })
|
||||||
export class FieldOption extends BaseEntity {
|
export class FieldOption extends BaseEntity {
|
||||||
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
[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 { FieldOption } from './field-option.entity';
|
||||||
import { EntityType, FieldType } from '../interface/print';
|
import { EntityType, FieldType } from '../interface/print';
|
||||||
import { BaseEntity } from 'src/common/entities/base.entity';
|
import { BaseEntity } from 'src/common/entities/base.entity';
|
||||||
|
|
||||||
|
|
||||||
@Entity({ tableName: 'field' })
|
@Entity({ tableName: 'field' })
|
||||||
|
@Index({ properties: ['entityId'] })
|
||||||
export class Field extends BaseEntity {
|
export class Field extends BaseEntity {
|
||||||
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
||||||
|
|
||||||
@@ -16,7 +17,7 @@ export class Field extends BaseEntity {
|
|||||||
entityType: EntityType;
|
entityType: EntityType;
|
||||||
|
|
||||||
// Foreign key based on entityType
|
// Foreign key based on entityType
|
||||||
@Property({ type: 'string',columnType:'char(26)' })
|
@Property({ type: 'string', columnType: 'char(26)' })
|
||||||
entityId: string;
|
entityId: string;
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
|
|||||||
@@ -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 { Product } from 'src/modules/product/entities/product.entity';
|
||||||
import { BaseEntity } from 'src/common/entities/base.entity';
|
import { BaseEntity } from 'src/common/entities/base.entity';
|
||||||
import { Invoice } from './invoice.entity';
|
import { Invoice } from './invoice.entity';
|
||||||
@@ -6,6 +6,7 @@ import { Order } from 'src/modules/order/entities/order.entity';
|
|||||||
|
|
||||||
|
|
||||||
@Entity({ tableName: 'invoice_items' })
|
@Entity({ tableName: 'invoice_items' })
|
||||||
|
@Index({ properties: ['invoice'] })
|
||||||
export class InvoiceItem extends BaseEntity {
|
export class InvoiceItem extends BaseEntity {
|
||||||
[OptionalProps]?: 'createdAt' | 'deletedAt' | 'discount' | 'description' | 'confirmedAt';
|
[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 { BaseEntity } from '../../../common/entities/base.entity';
|
||||||
import { User } from '../../user/entities/user.entity';
|
import { User } from '../../user/entities/user.entity';
|
||||||
import { NotifTitle } from '../interfaces/notification.interface';
|
import { NotifTitle } from '../interfaces/notification.interface';
|
||||||
import { Admin } from 'src/modules/admin/entities/admin.entity';
|
import { Admin } from 'src/modules/admin/entities/admin.entity';
|
||||||
|
|
||||||
@Entity({ tableName: 'notifications' })
|
@Entity({ tableName: 'notifications' })
|
||||||
|
@Index({ properties: ['user'] })
|
||||||
export class Notification extends BaseEntity {
|
export class Notification extends BaseEntity {
|
||||||
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ import { OrderPrint } from './print.entity';
|
|||||||
|
|
||||||
@Entity({ tableName: 'orders' })
|
@Entity({ tableName: 'orders' })
|
||||||
@Index({ properties: ['user'] })
|
@Index({ properties: ['user'] })
|
||||||
|
@Index({ properties: ['designer'] })
|
||||||
|
@Index({ properties: ['status'] })
|
||||||
export class Order extends BaseEntity {
|
export class Order extends BaseEntity {
|
||||||
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
[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 { Product } from 'src/modules/product/entities/product.entity';
|
||||||
import { BaseEntity } from 'src/common/entities/base.entity';
|
import { BaseEntity } from 'src/common/entities/base.entity';
|
||||||
import { Request } from './request.entity';
|
import { Request } from './request.entity';
|
||||||
import { IAttachment, IField } from '../interface/request.interface';
|
import { IAttachment, IField } from '../interface/request.interface';
|
||||||
|
|
||||||
@Entity({ tableName: 'request_items' })
|
@Entity({ tableName: 'request_items' })
|
||||||
|
@Index({ properties: ['request'] })
|
||||||
export class RequestItem extends BaseEntity {
|
export class RequestItem extends BaseEntity {
|
||||||
[OptionalProps]?: 'createdAt' | 'deletedAt';
|
[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 { BaseEntity } from '../../../common/entities/base.entity';
|
||||||
import { Role } from './role.entity';
|
import { Role } from './role.entity';
|
||||||
import { PermissionEnum } from 'src/common/enums/permission.enum';
|
import { PermissionEnum } from 'src/common/enums/permission.enum';
|
||||||
@@ -6,7 +6,7 @@ import { PermissionEnum } from 'src/common/enums/permission.enum';
|
|||||||
@Entity({ tableName: 'permissions' })
|
@Entity({ tableName: 'permissions' })
|
||||||
export class Permission extends BaseEntity {
|
export class Permission extends BaseEntity {
|
||||||
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
||||||
|
|
||||||
@Enum(() => PermissionEnum)
|
@Enum(() => PermissionEnum)
|
||||||
name!: PermissionEnum;
|
name!: PermissionEnum;
|
||||||
|
|
||||||
|
|||||||
@@ -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 { Role } from './role.entity';
|
||||||
import { Permission } from './permission.entity';
|
import { Permission } from './permission.entity';
|
||||||
|
|
||||||
@Entity({ tableName: 'role_permissions' })
|
@Entity({ tableName: 'role_permissions' })
|
||||||
|
@Index({ properties: ['role'] })
|
||||||
export class RolePermission {
|
export class RolePermission {
|
||||||
// دو ManyToOne دقیقاً؛ هر کدام میتونن primary: true باشند برای composite PK
|
// دو ManyToOne دقیقاً؛ هر کدام میتونن primary: true باشند برای composite PK
|
||||||
@ManyToOne(() => Role, { primary: true })
|
@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 { BaseEntity } from 'src/common/entities/base.entity';
|
||||||
import { TicketStatusEnum } from '../enum/status.enum';
|
import { TicketStatusEnum } from '../enum/status.enum';
|
||||||
import { IAttachment } from 'src/modules/order/interface/order.interface';
|
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';
|
import { User } from 'src/modules/user/entities/user.entity';
|
||||||
|
|
||||||
@Entity({ tableName: 'tickets' })
|
@Entity({ tableName: 'tickets' })
|
||||||
|
@Index({ properties: ['user'] })
|
||||||
export class Ticket extends BaseEntity {
|
export class Ticket extends BaseEntity {
|
||||||
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { Criticism } from '../../criticisms/entities/criticism.entity';
|
|||||||
|
|
||||||
|
|
||||||
@Entity({ tableName: 'users' })
|
@Entity({ tableName: 'users' })
|
||||||
|
@Index({properties:['phone']})
|
||||||
export class User extends BaseEntity {
|
export class User extends BaseEntity {
|
||||||
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
[OptionalProps]?: 'createdAt' | 'deletedAt'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user