This repository was archived by the owner on Apr 4, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { Column , Entity , PrimaryGeneratedColumn } from "../../../../src" ;
2
+
3
+ enum FooEnum { FOO , BAR }
4
+
5
+ class ParentEntity {
6
+ @PrimaryGeneratedColumn ( )
7
+ ud : number
8
+
9
+ @Column ( {
10
+ type : 'enum' ,
11
+ enum : FooEnum ,
12
+ enumName : 'foo_enum' ,
13
+ } )
14
+ foo : FooEnum ;
15
+ }
16
+
17
+ @Entity ( )
18
+ export class ChildEntity1 extends ParentEntity { }
19
+
20
+ @Entity ( )
21
+ export class ChildEntity2 extends ParentEntity { }
Original file line number Diff line number Diff line change
1
+ import "reflect-metadata" ;
2
+ import { Connection } from "../../../src" ;
3
+ import { createTestingConnections , closeTestingConnections } from "../../utils/test-utils" ;
4
+ import { ChildEntity1 , ChildEntity2 } from "./entity/Test" ;
5
+
6
+ describe ( "github issues > #7523 Do not create duplicate CREATE TYPE migration query when same 'enumName's are exists" , ( ) => {
7
+ let connections : Connection [ ] ;
8
+ before ( async ( ) => connections = await createTestingConnections ( {
9
+ enabledDrivers : [ "postgres" ] ,
10
+ schemaCreate : false ,
11
+ dropSchema : true ,
12
+ entities : [ ChildEntity1 , ChildEntity2 ] ,
13
+ } ) ) ;
14
+ after ( ( ) => closeTestingConnections ( connections ) ) ;
15
+
16
+ it ( "should recognize model changes" , ( ) => Promise . all ( connections . map ( async connection => {
17
+ const sqlInMemory = await connection . driver . createSchemaBuilder ( ) . log ( ) ;
18
+ sqlInMemory . upQueries . length . should . be . greaterThan ( 0 ) ;
19
+ sqlInMemory . downQueries . length . should . be . greaterThan ( 0 ) ;
20
+ } ) ) ) ;
21
+
22
+ it ( "should not generate queries when no model changes" , ( ) => Promise . all ( connections . map ( async connection => {
23
+ await connection . driver . createSchemaBuilder ( ) . build ( ) ;
24
+ const sqlInMemory = await connection . driver . createSchemaBuilder ( ) . log ( ) ;
25
+ sqlInMemory . upQueries . length . should . be . equal ( 0 ) ;
26
+ sqlInMemory . downQueries . length . should . be . equal ( 0 ) ;
27
+ } ) ) ) ;
28
+ } ) ;
You can’t perform that action at this time.
0 commit comments