remove generation of PK indices
This commit is contained in:
		
							parent
							
								
									d797c3d06d
								
							
						
					
					
						commit
						f346c0b904
					
				| @ -31,11 +31,24 @@ export default function modelCustomizationPhase( | ||||
| } | ||||
| function removeIndicesGeneratedByTypeorm(dbModel: Entity[]): Entity[] { | ||||
|     // TODO: Support typeorm CustomNamingStrategy
 | ||||
|     // TODO: PK index - ignores primaryKeyName(typeorm bug?) - to investigate
 | ||||
|     const namingStrategy = new DefaultNamingStrategy(); | ||||
|     dbModel.forEach(entity => { | ||||
|         entity.indices = entity.indices.filter( | ||||
|             v => !v.name.startsWith(`sqlite_autoindex_`) | ||||
|             v => | ||||
|                 !v.name.startsWith(`sqlite_autoindex_`) && | ||||
|                 (v.name !== "PRIMARY" && v.primary) | ||||
|         ); | ||||
|         const primaryColumns = entity.columns | ||||
|             .filter(v => v.primary) | ||||
|             .map(v => v.tscName); | ||||
|         entity.indices = entity.indices.filter( | ||||
|             v => | ||||
|                 v.primary && | ||||
|                 v.name !== | ||||
|                     namingStrategy.primaryKeyName( | ||||
|                         entity.tscName, | ||||
|                         primaryColumns | ||||
|                     ) | ||||
|         ); | ||||
|         entity.relations | ||||
|             .filter(v => v.joinColumnOptions) | ||||
|  | ||||
| @ -42,6 +42,6 @@ export class {{toEntityName tscName}}{{#activeRecord}} extends BaseEntity{{/acti | ||||
| } | ||||
| {{/inline}} | ||||
| import {BaseEntity,Column,Entity,Index,JoinColumn,JoinTable,ManyToMany,ManyToOne,OneToMany,OneToOne,PrimaryColumn,PrimaryGeneratedColumn,RelationId} from "typeorm"; | ||||
| {{#fileImports}}{{> Import}}{{/fileImports~}} | ||||
| {{#fileImports}}{{> Import}}{{/fileImports}} | ||||
| 
 | ||||
| {{~> Entity}} | ||||
| {{> Entity}} | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user