Comments
2 comments
-
The PostgreSQL documentation mentions this:- Clean does not remove objects created by extensions. It is therefore highly recommended to create your extensions using
CREATE EXTENSION IF NOT EXISTSin order to be able to clean and (re-)migrate your schemas at will
- Clean does not remove objects created by extensions. It is therefore highly recommended to create your extensions using
-
From what you've shared, this is most likely expected behavior rather than a configuration issue. Flyway's
cleancommand is designed to remove objects it manages, but foreign tables created throughpostgres_fdwaren't always handled the same way because they depend on external server definitions and object dependencies.If your migration process creates those foreign tables, you may need to explicitly drop them in a separate migration or pre-clean script before running
clean. That's generally a safer approach than expecting Flyway to remove every dependency automatically.I usually think of it as any other clean up process. Whether you're cleaning up a database or dealing with something like mold clean up, it's important to understand what's connected to the underlying source before removing objects. Otherwise, you can end up with leftover dependencies or create new issues that are harder to troubleshoot later.
One question: are the foreign tables created entirely by your migrations, or were they already present before Flyway started managing the database? That detail will help determine the best approach.
Add comment
Please sign in to leave a comment.
Using flyway 8.5.13 and attempting again with flyway 10.18.1 (latest version currently), running the clean function does not drop foreign tables. Is this a limitation or is it possible to drop foreign tables using flyway clean?
The following .bat file is used via flyway CLI:
Control and schema1 get cleaned (tables and views) whereas schema2_fs does not get cleaned as it only contains foreign tables setup with a foreign server as follows:
Any help would be appreciated, as we are currently running migrations using "IF NOT EXISTS" when creating foreign tables and DROP when we could be using ALTER.