fix: check a copy's source for hypertables again once it is dumped

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-11-29 12:30:02 +01:00
co-authored by Claude Opus 5.5
parent e179bc49d5
commit ffc61a6ea6
3 changed files with 13 additions and 2 deletions
@@ -469,7 +469,7 @@ async fn make_copy(
// except on a cluster Windmill manages, which plants its own and where the replay below is what
// reproduces the roles'.
let extensions = read_extension_plan(db, &server, schema_only).await?;
let dump = extensions.dump(&server, schema_only, managed).await?;
let dump = extensions.dump(db, &server, schema_only, managed).await?;
let applied = match migrations_lock {
Some(client) => Some(read_applied_migrations(&client).await?),
None => None,
@@ -198,6 +198,7 @@ impl ExtensionPlan {
/// carries over, as the restore runs as the target's connection user.
pub(crate) async fn dump(
&self,
db: &DB,
source: &PgDatabase,
schema_only: bool,
no_acl: bool,
@@ -219,6 +220,16 @@ impl ExtensionPlan {
},
)
.await?;
// A hypertable made since the plan was read would be dumped as a plain table without its
// chunks. One made after the dump's snapshot is not in the dump at all.
if self.extensions.iter().any(|e| e.name == TIMESCALEDB) {
let (client, connection) = source.connect(Some(db)).await?;
let join_handle = tokio::spawn(async move { connection.await });
let refused = refuse_hypertables(&client, &source.dbname).await;
drop(client);
windmill_common::shutdown_pg_connection(join_handle).await?;
refused?;
}
let list = self.restore_list(&archive).await?;
pg_restore_script(
&archive,
@@ -4454,7 +4454,7 @@ async fn import_pg_database(
};
let extensions =
crate::datatable_extensions::read_extension_plan(&db, &source_pg, schema_only).await?;
let dump = extensions.dump(&source_pg, schema_only, no_acl).await?;
let dump = extensions.dump(&db, &source_pg, schema_only, no_acl).await?;
let applied = match migrations_lock {
Some(client) => Some(crate::datatable_migrations::read_applied_migrations(&client).await?),
None => None,