-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Closed
Copy link
Labels
Description
Issue description
When I modify enum in column with simple-enum type to include some new values, they do not appear in database schema after I run sync or create a new migration.
Expected Behavior
If values of enum in column with type simple-enum was changed, sync/migration must add changed values to CHECK( "column_name" IN ('enumvalue1','enumvalue2','enumvalue3','enumvalue4') ) constraint of column definition in database schema.
Actual Behavior
Sync/migration ignores fact that enum values was changed and does not update CHECK constraint to include new values.
Steps to reproduce
- Create an Entity with column that have
simple-enumtype.
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
export enum ExampleEnum {
EnumValue1 = 'enumvalue1',
EnumValue2 = 'enumvalue2',
EnumValue3 = 'enumvalue3',
}
@Entity()
export class EntityWithEnum {
@PrimaryGeneratedColumn()
id: number;
@Column({
type: 'simple-enum',
enum: ExampleEnum,
})
enumcolumn: ExampleEnum;
@Column()
name: string;
}- Execute sync:
npm run typeorm schema:sync- Add new enum value:
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
export enum ExampleEnum {
EnumValue1 = 'enumvalue1',
EnumValue2 = 'enumvalue2',
EnumValue3 = 'enumvalue3',
+ EnumValue4 = 'enumvalue4',
}
@Entity()
export class EntityWithEnum {
@PrimaryGeneratedColumn()
id: number;
@Column({
type: 'simple-enum',
enum: ExampleEnum,
})
enumcolumn: ExampleEnum;
@Column()
name: string;
}- Execute DB sync again:
npm run typeorm schema:sync- See that
CHECK( "enumcolumn" IN ('enumvalue1','enumvalue2','enumvalue3') )constraint in column definition of database schema does not include addition ofenumvalue4.
My Environment
| Dependency | Version |
|---|---|
| Operating System | macOS |
| Node.js version | 18.12.1 |
| Typescript version | 4.7.4 |
| TypeORM version | 0.3.11 |
Additional Context
Similar issue but with MS SQL Server: #9457
Relevant Database Driver(s)
- aurora-mysql
- aurora-postgres
- better-sqlite3
- cockroachdb
- cordova
- expo
- mongodb
- mysql
- nativescript
- oracle
- postgres
- react-native
- sap
- spanner
- sqlite
- sqlite-abstract
- sqljs
- sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
Yes, I have the time, but I don't know how to start. I would need guidance.