You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At first: Thanks for this awesome library! I really like the developer experience and the code base is one of the cleanest in TS I've seen so far. 馃帀
Describe the bug
Adding a custom type, in my case a StringArrayType which is basically the solution provided here, results in the migration creation to generate the "dirty" migration file. My type looks like this:
import { Type } from 'mikro-orm';
/**
* This type used until version 4 of mikro orm is released as it supports array types natively
*/
class StringArrayType extends Type {
convertToDatabaseValue(javascriptValue?: string[]) {
const stringValues = javascriptValue?.map(value => JSON.stringify(value)).join(',');
return `{${stringValues}}`;
}
toJSON(javascriptValue: string[]) {
return JSON.stringify(javascriptValue);
}
convertToJSValue(databaseValue: string) {
return databaseValue;
}
getColumnType(){
return 'text[]';
}
}
export default StringArrayType;
I found out, that the database returns a udt_name of _text which does neither match the provided type from getColumnType nor the types provided in the PostgreSqlSchemaHelper.TYPES. Adding textArray: ['_text', 'text[]'], to the TYPES object resolves the issue for me. If this solution is viable for mikro-orm I'm happy to provide a pull request - However, I think this is not the best solution.
To Reproduce
Steps to reproduce the behavior:
Add the custom type specified above as a type on an entity
Create an migration with yarn mikro-orm migration:create
Migrate the database with yarn mikro-orm migration:up
Create another migration with yarn mikro-orm migration:create
Observed behavior
The migration contains something like the following:
this.addSql('alter table "events" drop constraint if exists "events_genres_check";');
this.addSql('alter table "events" alter column "genres" type text[] using ("genres"::text[]);');
Even if you keep this, run the migration and create another one, a similar file is always created. Expected behavior
The created migration should be empty as no changes have happend.
Versions
Dependency
Version
node
v14.4.0
typescript
3.9.6
mikro-orm
3.6.15
pg
8.3.0
The text was updated successfully, but these errors were encountered:
Ok, so closing this as resolved in v4 (I am not planning to ship more v3 releases).
How is the current estimation for the release?
Will be merging it during the weekend and releasing RC. Then probably week or two to adjust docs and write a release article, but in general its ready.
Is there anything I can do to help?
Migrate to v4 and test it :] I am using the latest alpha in my production app, working fine for me, so I'd say nothing to be afraid of, especially if you have your app covered with tests.
Hey folks!
At first: Thanks for this awesome library! I really like the developer experience and the code base is one of the cleanest in TS I've seen so far. 馃帀
Describe the bug
Adding a custom type, in my case a StringArrayType which is basically the solution provided here, results in the migration creation to generate the "dirty" migration file. My type looks like this:
I found out, that the database returns a
udt_name
of_text
which does neither match the provided type fromgetColumnType
nor the types provided in thePostgreSqlSchemaHelper.TYPES
. AddingtextArray: ['_text', 'text[]'],
to theTYPES
object resolves the issue for me. If this solution is viable for mikro-orm I'm happy to provide a pull request - However, I think this is not the best solution.To Reproduce
Steps to reproduce the behavior:
yarn mikro-orm migration:create
yarn mikro-orm migration:up
yarn mikro-orm migration:create
Observed behavior
The migration contains something like the following:
Even if you keep this, run the migration and create another one, a similar file is always created.
Expected behavior
The created migration should be empty as no changes have happend.
Versions
The text was updated successfully, but these errors were encountered: