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 EXISTSqueries 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 becauseUSINGshould be followed by the index type.Indexand its subclasses withschema_generator, hence makingschema_generatora single place to have schema generation logic. This also also makes theIndexandschema_generatorrelation one directional.Model.describewhenIndexis inModel.Meta.indexesMotivation and Context
This should fix #1836.
How Has This Been Tested?
make ciI also tested the generated SQLs against corresponding databases.
Checklist: