Open cloud303-mbrughelli opened 7 months ago
So you have auth.user
table, you have an entity for it, and you want to ignore the rest of the schema? And you want to have only some columns mapped in your entity? Limiting what we infer from existing schema when diffing?
So you have
auth.user
table, you have an entity for it, and you want to ignore the rest of the schema? And you want to have only some columns mapped in your entity? Limiting what we infer from existing schema when diffing?
That is correct. I realize it's not critical and there are plenty of workarounds. Just an idea I had based on the functionality existing in the other direction (Entity Generator). I appreciate the response! Mikro- Orm is the GOAT, really loving it. Thank you for your work.
I would love for a way to create indexes that aren't even considered by the schema migrator. I am creating some manual indexes that I don't think I can create using the decorators. Here is an example (I'm using postgresql):
create index "manual_blog_post_search_index" on "blog_post" ("user_id", lower("title") collate "C", "created_at", "category_id");
In this case I need lower("title")
so that I can do a case-insensitive prefix search on the title
, and I need to use collate "C"
because postgresql requires this collation for prefix search using the ^@
operator.
For context, I use this in my query:
[raw('lower("title") ^@ ?', [titlePrefix])]: [],
So this is an example of an index that I don't think mikro-orm can create using the decorators, which is fine because I am perfectly happy creating them manually. But the annoying part is that the migration generator wants to remove them. ðŸ˜
I think one simple solution would be to ignore indexes whose name doesn't start with the table name. All mikro-orm indexes starts with the table name (e.g. blog_post_
), so if I prefix my manual indexes with something else (manual_
in this example), then it would be great if mikro-orm used that to understand that it did not create this index and thus it shouldn't try to remove it.
I hope that makes sense. :)
You can create any index via index expressions, see the title
property in this example https://mikro-orm.io/docs/defining-entities#indexes.
Is your feature request related to a problem? Please describe. Piggy-backing off this issue that was implemented: issue , I'd like the ability to skip certain tables or columns during schema generation. I am using supabase which has an auth schema by default that has a users table that I want the entity for but many other tables that I don't need. I do have "auth" set in the ignoreSchema array option on the schemaGenerator in my config. But obviously that makes the generator think that auth.users needs to be created. If I remove "auth" from the array, it tries to remove everything from auth that isn't the users table.
Describe the solution you'd like A skipTables and skipColumns option in the schemaGenerator.
Describe alternatives you've considered I've moved on by defining a normal PK for my public.profile table that is not linked to the foreign users key in the auth schema. This is not ideal as it's important to me to maintain the FK constraints.