Skip to content

v1.0.9

Latest

Choose a tag to compare

@jtayal-stripe jtayal-stripe released this 06 Aug 09:59
v1.0.9
9ada471

Fix: Materialized view reconstruction uses WITH NO DATA

During plan validation, setSchemaForEmptyDatabase reconstructs the source schema in a temporary database. For materialized views, the Add() method previously emitted CREATE MATERIALIZED VIEW ... AS <query> without WITH NO DATA, causing Postgres to execute the view's stored query. This is unnecessary (the temp DB is discarded immediately) and potentially unsafe.

Changes

  • Append WITH NO DATA to all CREATE MATERIALIZED VIEW DDL generated during schema reconstruction
  • Strip trailing semicolons from pg_get_viewdef() output to prevent syntax errors when appending WITH NO DATA

Files changed

  • pkg/diff/materialized_view_sql_generator.go
  • pkg/diff/schema_migration_plan_test.go (3 new unit tests)

Full PR: #305