-
-
Notifications
You must be signed in to change notification settings - Fork 400
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
Fix index creation in Tortoise.generate_schemas() for MySQL and Postgres #1847
Fix index creation in Tortoise.generate_schemas() for MySQL and Postgres #1847
Conversation
CodSpeed Performance ReportMerging #1847 will not alter performanceComparing Summary
|
Pull Request Test Coverage Report for Build 12751398752Details
💛 - Coveralls |
@waketzheng what do you think about this approach? Even though it moves more code - I think end result seems a bit clearer, as we don't introduce new entities and improve existing code by moving out dialect-specific schema generation code to it's intended place |
Looks good. @henadzit Cloud you add more test cases? For example, add |
Will do! |
a833893
to
6ce5711
Compare
I added tests and fixed the issue with using |
Description
CREATE INDEX IF NOT EXISTS
queries with indexes defined inside the table definition for MySQLCREATE INDEX "idx_index_partial_c5be6a" ON "index" USING ("partial") WHERE id = 1;
isn't correct syntax becauseUSING
should be followed by the index type.Index
and its subclasses withschema_generator
, hence makingschema_generator
a single place to have schema generation logic. This also also makes theIndex
andschema_generator
relation one directional.Model.describe
whenIndex
is inModel.Meta.indexes
Motivation and Context
This should fix #1836.
How Has This Been Tested?
make ci
I also tested the generated SQLs against corresponding databases.
Checklist: