-
-
Notifications
You must be signed in to change notification settings - Fork 496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible problem with migration diff with enums involved. #1142
Comments
I think I found one problem: I changed the entity definition for the 2 enums from @Enum({ type: "MailType", items: () => MailType, default: MailType.Unknown })
mailType: MailType // FIXME: set default value how?
@Enum({
type: "RelatedType",
items: () => RelatedType,
default: RelatedType.None,
nullable: true,
})
relatedType?: RelatedType to @Enum({ default: MailType.Unknown })
mailType: MailType
@Enum({ default: RelatedType.None, nullable: true })
relatedType?: RelatedType It seems that defining Changing the enum definition does create them the same way they were (int2), but does not cause the newly created migration to contain schema changes over and over. A newly created migration is empty as it should be. However, the initial migration created from the existing schema was still not logged to the migrations table. I'll try to figure out what causes this. |
I think I found why the initial migration doesn't get logged. I'm logging all the table names that are found in the database versus all those found in the schema. They can't match. schema.getTables().forEach(table => {
/* istanbul ignore next */
const tableName = table.schema ? `${table.schema}.${table.name}` : table.name;
console.log("found table ", tableName, expected.has(tableName));
if (expected.has(tableName)) {
exists.add(tableName);
}
}); Here's the names found in the DB (second are is
Here's the set of expected entries:
The set of existing entries is empty. |
Fixed in |
Describe the bug
I think I see a bug with schema diffing (or migration) for my app using a Postgresql db:
I created an initial migration (using
migrator.createInitialMigration()
) from an existing schema (one that was updated throughorm.getSchemaGenerator().updateSchema()
.schemaExists
returned false.migrate up
using the initial migration file. This worked fine.relatedType
andmailType
fromqueued-mail.entity.ts
.I attach the following files:
Let me know if I can debug anything to help sort this out! Thanks!
migration-issue.zip
To Reproduce
Steps to reproduce the behavior:
I'm sorry I don't have a reproduction repo yet. Please let me know if you need one.
Expected behavior
Additional context
Add any other context about the problem here.
Versions
pg
from mikro-ormThe text was updated successfully, but these errors were encountered: