Source versioning allows you to incorporate schema changes from upstream databases with zero downtime in Materialize. With this release, you can now handle adding a new column, or dropping a column, in a PostgreSQL source connected to Materialize.
To allow source versioning, we’ve significantly rebuilt how sources work in Materialize. And we’ve made a slight modification to the syntax for creating a source. The code block below shows what it now looks like to create a source which can handle upstream schema changes.
-- Create the source from a connection:
CREATE SOURCE IF NOT EXISTS my_source
FROM POSTGRES CONNECTION pg_connection (PUBLICATION mz_source);
-- Create a table to represent the upstream table which you want to replicate:
CREATE SCHEMA v1;
CREATE TABLE v1.T
FROM SOURCE my_source(REFERENCE public.T);If you’re not ready to use the new syntax yet, don’t worry - the old syntax will continue to be supported.
Follow our detailed guide here for a tutorial on how to handle adding a new column, or dropping a column, from your upstream source PostgreSQL database. This feature is available in private preview for Materialize Cloud and Materialize Self-Managed (v26.0.0+). Contact us for access to this feature.