Adding an enum field does not generate a migration
See original GitHub issueIssue Description
When I add an enum item to an existing enum field on an Entity and run migration:generate
, a blank migration is created
Expected Behavior
I expect a migration to be created to add add the field to the Postgres database
Actual Behavior
An empty migration is created
Steps to Reproduce
- Add an entity with an enum field:
export enum Status {
Live = 'live',
Draft = 'draft',
Archived = 'archived',
}
@Entity({ name: 'something' })
export class Something {
@Column({
type: 'enum',
enum: Status,
default: Status.Draft,
})
status: OrganisationVersionStatus;
}
- Generate and run the migrations
- Add another enum field:
export enum Status {
Live = 'live',
Draft = 'draft',
Archived = 'archived',
Unconfirmed = 'unconfirmed',
}
@Entity({ name: 'something' })
export class Something {
@Column({
type: 'enum',
enum: Status,
default: Status.Draft,
})
status: OrganisationVersionStatus;
}
- Generate the migrations
- Result:
export class AddUnconfirmedStatusToSomething643119746947 implements MigrationInterface
{
name = 'AddUnconfirmedStatusToSomething1643119746947';
public async up(queryRunner: QueryRunner): Promise<void> {}
public async down(queryRunner: QueryRunner): Promise<void> {}
}
My Environment
Dependency | Version |
---|---|
Operating System | Mac OS |
Node.js version | 16.13.0 |
Typescript version | 4.4.4 |
TypeORM version | 0.2.40 |
Additional Context
Relevant Database Driver(s)
DB Type | Reproducible |
---|---|
aurora-data-api |
no |
aurora-data-api-pg |
no |
better-sqlite3 |
no |
cockroachdb |
no |
cordova |
no |
expo |
no |
mongodb |
no |
mysql |
no |
nativescript |
no |
oracle |
no |
postgres |
yes |
react-native |
no |
sap |
no |
sqlite |
no |
sqlite-abstract |
no |
sqljs |
no |
sqlserver |
no |
Are you willing to resolve this issue by submitting a Pull Request?
- ✖️ Yes, I have the time, and I know how to start.
- ✖️ Yes, I have the time, but I don’t know how to start. I would need guidance.
- ✖️ No, I don’t have the time, but I can support (using donations) development.
- ✅ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
Issue Analytics
- State:
- Created 2 years ago
- Comments:10
Top Results From Across the Web
Add new enum column during migration - Stack Overflow
Modify your schema and don't build yet the model. run doctrine schema diff then a migration class will be generated for you. Finally...
Read more >How to Use Enums in Rails | Saeloun Blog
We run the migration using rake db:migrate and in our Post model, we need to define the enum as shown in the below...
Read more >Migrations uses value of enum object instead of its name.
When using Enum object as a default value for a CharField, the generated migration file uses the value of the Enum object instead...
Read more >Postgres: Enum type fields | Hasura GraphQL Docs
New values cannot be added to an enum inside a transaction (that is, ALTER TYPE ... ADD VALUE is not supported by transactional...
Read more >Upgrading PostgreSQL's Enum type with SQLAlchemy using ...
In this tutorial we've successfully generated the migration file which can automatically upgrade enum types on PostgreSQL server. If you want to ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Ginden I’m using NestJS, but I think this is the pertinent bit of my config:
can you share your entity after the latest change you made?