Skip to content

Drop type cascade in drop_everything#3014

Open
Huliiiiii wants to merge 1 commit intoSeaQL:masterfrom
Huliiiiii:drop-everything-cascade
Open

Drop type cascade in drop_everything#3014
Huliiiiii wants to merge 1 commit intoSeaQL:masterfrom
Huliiiiii:drop-everything-cascade

Conversation

@Huliiiiii
Copy link
Member

PR Info

Bug Fixes

  • [sea-orm-migration] PostgreSQL drop_everything now drops custom types with CASCADE

@Huliiiiii Huliiiiii requested a review from tyt2y3 March 19, 2026 13:20
@Huliiiiii Huliiiiii force-pushed the drop-everything-cascade branch from 45ff08b to 8979af0 Compare March 19, 2026 13:20
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8979af09a5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Huliiiiii Huliiiiii force-pushed the drop-everything-cascade branch from 8979af0 to 7374b89 Compare March 19, 2026 14:11
@Huliiiiii
Copy link
Member Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7374b89422

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

info!("Dropping type '{}'", type_name);
let mut stmt = Type::drop();
stmt.name(Alias::new(&type_name));
stmt.name(Alias::new(&type_name)).if_exists().cascade();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restrict cascading type drops to the target schema

query_pg_types() intentionally limits this cleanup to get_current_schema(db) (sea-orm-migration/src/migrator/queries.rs:117-142), and the migration tests explicitly support custom schema_search_path values (sea-orm-migration/tests/main.rs:58-63). Adding CASCADE here changes the failure mode for PostgreSQL: if another schema has a table/function/operator that references one of these types, DROP TYPE ... CASCADE will recursively delete that external object instead of stopping with a dependency error. In shared-database or multi-schema deployments, Migrator::fresh() can now destroy objects outside the schema it is supposed to be refreshing.

Useful? React with 👍 / 👎.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that’s the problem. Users might not want objects in other schemas to get dropped. I think we can add a flag to control this behavior.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts, @tyt2y3?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[sea-orm-migration] Drop dependant object on fresh operations

1 participant