sea-orm
sea-orm copied to clipboard
[CLI] Error when running `migrate fresh` when using pg_trgm extension
Description
When using the pg_trgm PostgreSQL extension, I'm not able to run the migrate fresh command.
Dropping all types
Dropping type 'gtrgm'
Execution Error: error returned from database: cannot drop type gtrgm because extension pg_trgm requires it
Fail to run migration
Steps to Reproduce
Create the pg_trgm extension
CREATE EXTENSION IF NOT EXISTS pg_trgm
OR
use sea_orm_migration::prelude::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
let db = manager.get_connection();
db.execute_unprepared(
"--sql
CREATE EXTENSION IF NOT EXISTS pg_trgm",
)
.await?;
Ok(())
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
let db = manager.get_connection();
db.execute_unprepared(
"--sql
DROP EXTENSION IF EXISTS pg_trgm",
)
.await?;
Ok(())
}
}
Now run
sea migrate fresh
Expected Behavior
sea-orm-cli should be able to fresh start a new schema.
Actual Behavior
The command is failing.
Reproduces How Often
Always
Workarounds
sea-orm-cli migrate refresh and sea-orm-cli migrate reset both works.
However, sometimes the schema is just dirty, and I need to start fresh without having every down migration ready.
Reproducible Example
https://github.com/SeaQL/sea-orm/tree/master/issues/2610
Versions
sea-orm-cli 1.1.11