sea-orm
sea-orm copied to clipboard
Migrate fresh not deleting postgres type
Description
If the migration creates postgres types, running sea-orm-cli migrate fresh
will fail because it doesn't delete types, and it will say that the type already exists.
Steps to Reproduce
- Create a migration which creates a postgres type.
- Run the migration
sea-orm-cli migrate up
- Try to run a fresh migration
sea-orm-cli migrate fresh
Expected Behavior
The fresh migration should work
Actual Behavior
The fresh migration returns an error saying that the enum type already exists.
Reproduces How Often
always
Versions
│ └── sea-orm v0.8.0 │ ├── sea-orm-macros v0.8.0 (proc-macro) │ ├── sea-query v0.24.6 │ │ ├── sea-query-derive v0.2.0 (proc-macro) │ │ ├── sea-query-driver v0.1.1 (proc-macro) │ ├── sea-strum v0.23.0 │ │ └── sea-strum_macros v0.23.0 (proc-macro) │ ├── sea-orm-migration v0.8.2 │ │ ├── sea-orm v0.8.0 () │ │ ├── sea-orm-cli v0.8.1 │ │ │ ├── sea-schema v0.8.0 │ │ │ │ ├── sea-query v0.24.6 () │ │ │ │ └── sea-schema-derive v0.1.0 (proc-macro) │ │ ├── sea-schema v0.8.0 () ├── sea-orm v0.8.0 () ├── sea-orm-rocket v0.5.0 │ └── sea-orm-rocket-codegen v0.5.0 (proc-macro)
uname -a
Linux arch 5.17.5-arch1-1 #1 SMP PREEMPT Wed, 27 Apr 2022 20:56:11 +0000 x86_64 GNU/Linux
pacman -Q postgresql
postgresql 14.2-1
Additional Information
Types should be first deleted when running a fresh migration.
Hey @MaderNoob, sorry for the delay. As discussed on Discord, we could delete all PostgreSQL types in current schema when calling fresh
on migrator.
- https://github.com/SeaQL/sea-orm/blob/9983e5d4987149ad227ccf402e4cf2618a1dddc3/sea-orm-migration/src/migrator.rs#L130-L212
It would be a two steps process:
- Select all type names out of PostgreSQL
- Construct delete type statement and execute it
I'll open this issue for anyone who have interested in contributing :)
@billy1624 can you assign me with this issue?
@karpa4o4 done!
@ikrivosheev thanks
Thanks for the interest! @karpa4o4