Skip to content

Comments

Add clean command#200

Open
ragb wants to merge 6 commits intorolang:mainfrom
ragb:add-clean-command
Open

Add clean command#200
ragb wants to merge 6 commits intorolang:mainfrom
ragb:add-clean-command

Conversation

@ragb
Copy link

@ragb ragb commented Feb 3, 2026

Summary

  • Flyway-compatible clean command that drops all objects in configured schemas
  • Schemas created by Dumbo → dropped entirely (DROP SCHEMA CASCADE)
  • Pre-existing schemas → objects dropped individually following Flyway's doClean() order: materialized views, views, tables, base types (with recreate for circular deps), routines, enums, domains, sequences, base types (final cleanup)
  • Extension-owned objects excluded via pg_depend checks
  • cleanDisabled flag (default true) matching Flyway's safety default
  • CLI support via -cleanDisabled=false clean

- Flyway-compatible clean dropping all schema objects
- cleanDisabled flag (default: true) matching Flyway safety
- CLI support with -cleanDisabled option
- Flyway compatibility and unit tests
@ragb
Copy link
Author

ragb commented Feb 3, 2026

Hello. This is more an RFC than anything else. I was implementing this to replace flyway in some integration tests that use flyway clean. Just dropping all the schemas was not doing everyting I needed so I tried to replicate Flyway's behaviour as much as I can, and from what I understand. To be completely clear, I used an LLM to help with parts of this, namely testing.

Feel free to add to your project or. If it's out of scope all fine, I am already using a similar logic internaly for my usecase.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds a clean command to Dumbo that drops all database objects in configured schemas, providing Flyway-compatible behavior. The implementation distinguishes between schemas created by Dumbo (which are dropped entirely) and pre-existing schemas (where objects are dropped individually in a specific order).

Changes:

  • Implements runClean method with safety flag cleanDisabled (default: true)
  • Adds catalog queries to discover schema objects (materialized views, views, tables, types, routines, enums, domains, sequences)
  • Integrates clean command into CLI with -cleanDisabled flag
  • Includes comprehensive unit tests and Flyway compatibility tests

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
modules/core/shared/src/main/scala/dumbo/Dumbo.scala Main clean implementation with schema drop logic and object cleanup ordered to handle dependencies
modules/core/shared/src/main/scala/dumbo/internal/CatalogQueries.scala SQL queries to discover database objects, filtering out extension-owned objects
modules/core/shared/src/main/scala/dumbo/exception/DumboCleanException.scala New exception class for clean operation errors
modules/core/shared/src/main/scala/dumbo/History.scala Adds query to retrieve schemas created by Dumbo from history table
modules/cli/shared/src/main/scala/dumbo/cli/Dumbo.scala CLI command handler for clean operation
modules/cli/shared/src/main/scala/dumbo/cli/Arguments.scala Command and configuration definitions for clean
modules/tests/shared/src/test/scala/DumboMigrationSpec.scala Unit tests for clean functionality including idempotency and disabled flag
modules/tests/shared/src/main/scala/ffstest/FFramework.scala Test helper method for clean operations
modules/tests-flyway/src/test/scala/DumboFlywaySpec.scala Flyway compatibility tests verifying clean leaves schema in same state

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Log what was actually cleaned (dropped vs cleaned schemas) instead of all configured schemas
- Use parameterized query for progress monitor search_path comparison
- Add quoteIdentifier utility following PostgreSQL/Flyway identifier quoting
- Apply identifier quoting to all DDL statements using #$ interpolation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@rolang rolang self-requested a review February 10, 2026 02:08
@rolang
Copy link
Owner

rolang commented Feb 10, 2026

Thanks for the contribution @ragb . I will take a closer look myself when I have time, we can probably merge it. For now I let copilot have a look and check whether CI passes. Looks like the major version needs to be updated to 0.8 due to binary compatibility break. Also could you update the command line docs in readme with the new clean command?

@ragb
Copy link
Author

ragb commented Feb 10, 2026

Thanks for the contribution @ragb . I will take a closer look myself when I have time, we can probably merge it. For now I let copilot have a look and check whether CI passes. Looks like the major version needs to be updated to 0.8 due to binary compatibility break. Also could you update the command line docs in readme with the new clean command?

Will do. When reviewing, please note most of the copilot review comments make sense in general. I tried to follow what flyway does however, in the cases when I could improve easily, I did.

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.

2 participants