Skip to content

fix: cleanup_schema now drops functions for public schema cleanup#5

Open
affandar wants to merge 2 commits intomainfrom
fix/cleanup-schema-drops-functions
Open

fix: cleanup_schema now drops functions for public schema cleanup#5
affandar wants to merge 2 commits intomainfrom
fix/cleanup-schema-drops-functions

Conversation

@affandar
Copy link
Owner

@affandar affandar commented Jan 6, 2026

Summary

This PR fixes #4 - cleanup_schema() now drops all stored procedures in addition to tables, ensuring complete cleanup when using the public schema.

Problem

When using the public schema (default), the cleanup_schema() function only dropped tables, leaving stored procedures orphaned. This happened because:

  1. cleanup_schema() SQL function only had DROP TABLE statements
  2. The Rust code's safety check prevents DROP SCHEMA CASCADE on public schema
  3. Functions accumulated across test runs

Changes

Modified migrations/0002_create_stored_procedures.sql:

  • Added DROP FUNCTION IF EXISTS for all 22 stored procedures inside cleanup_schema()
  • Updated comments to clarify the function now drops both tables AND functions

Testing

  • All 99 tests in postgres_provider_test pass
  • Migration applies cleanly

Notes

This aligns duroxide-pg with the pattern already used in duroxide-pg-opt, which has comprehensive function drops in its cleanup_schema().

Affan Dar added 2 commits January 7, 2026 05:05
Previously, cleanup_schema() only dropped tables, which left stored procedures
orphaned when using the public schema. This was problematic because:

1. When using public schema, DROP SCHEMA CASCADE never runs (safety check)
2. Only the tables were dropped by cleanup_schema()
3. Stored procedures accumulated across test runs

This fix adds DROP FUNCTION IF EXISTS for all 22 stored procedures, ensuring
complete cleanup regardless of which schema is used.

Fixes #4
- Fixed cleanup_schema to drop stored procedures (issue #4)
- Fixed prune_executions_bulk to process Running instances
- Updated duroxide dependency to 0.1.11
- Added schema versioning documentation
- Added regression test for prune bulk behavior
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.

cleanup_schema() doesn't drop functions, leaving public schema dirty

1 participant