Open metakot opened 5 months ago
I think we should probably add an index_name
argument for situations like this.
The downside is migrations would have to be aware of this, and if the user changes index_name
we need to change it in the database. It's not too complex though:
ALTER INDEX name RENAME TO new_name
So I have this two tables in postgres:
The migration file is created successfully, but the migration itself ends with the error:
asyncpg.exceptions.DuplicateTableError: relation "employee_role" already exists
It turns out that piccolo generates the following SQL:
CREATE INDEX employee_role ON "employee" USING btree ("role");
And this clashes with the name of the table.The code for index name lives here:
To prevent that kind of name conflicts, can we add the suffix to the index name, like
_idx_XXXX
there X is the random hex symbol?UPD: however, in order to be able to gracefully undo the migration backwards the migration file must store the index name somethere or look it up from the database.