accounts
accounts copied to clipboard
Schema modification to change unsupported column type
Hi,
I am trying to use Accounts graphql module with MySql database in my app and I'm getting
Data type "jsonb" in "User.profile" is not supported by "mysql" database.
Is there a way how change the column type for User.profile
without actually modifying the compiled file (node_modules\@accounts\typeorm\lib\entity\UserService.js
)? There are more occurrences of the jsonb
type.
Thank you, Karel
I think for now the typeorm implementation is only working with postgresql
, can you confirm @birkir?
Yes but my plan was to add non-json column type sql support.
Actually I made sure to already split up the columns so that everything was prepared for this.
Just matter of using JSON.parse/stringify if column type is not json/json.
I will have time for this very soon.
@birkir the profile should be managed by the users see #617
@birkir @pradel there is another jsonb column in UserService class, the options property. Is it possible to modify it as well? also UserSession.extra property.
this type is not compatible with all databases
@lihaibh you are right, my bad I will reopen the issue
@birkir I don't really know how typeorm is working but is there a way to do some database specific logic? (eg use jsonb for postgres and use another table for mysql?) The problem I can see with json stringify / parse is that it will not be easy for the user to run some queries on these fields.
@pradel the only workaround I see is to use actual types as entities and OneToOne annotation and if its necessary to add fields we will have to extend these types. so for example for UserService.options:
@Column('jsonb', { nullable: true })
public options: { bcrypt: string } | any;
have to replace with:
@Column({ nullable: true })
@OneToOne(...)
public options: UserServiceOptions;