replica-identity.td 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. # IMPORTANT: The Postgres server has a custom pg_hba.conf that only
  10. # accepts connections from specific users. You will have to update
  11. # pg_hba.conf if you modify the existing user names or add new ones.
  12. > CREATE SECRET pgpass AS 'postgres'
  13. > CREATE CONNECTION pg TO POSTGRES (
  14. HOST postgres,
  15. DATABASE postgres,
  16. USER postgres,
  17. PASSWORD SECRET pgpass
  18. )
  19. $ postgres-execute connection=postgres://postgres:postgres@postgres
  20. ALTER USER postgres WITH replication;
  21. DROP SCHEMA IF EXISTS public CASCADE;
  22. CREATE SCHEMA public;
  23. DROP PUBLICATION IF EXISTS mz_source;
  24. CREATE PUBLICATION mz_source FOR ALL TABLES;
  25. CREATE TABLE tbl_a (pk INTEGER PRIMARY KEY);
  26. INSERT INTO tbl_a VALUES (1);
  27. > CREATE SOURCE mz_source FROM POSTGRES CONNECTION pg (PUBLICATION 'mz_source');
  28. ! CREATE TABLE tbl_a FROM SOURCE mz_source (REFERENCE tbl_a);
  29. contains:referenced items not tables with REPLICA IDENTITY FULL
  30. detail:referenced items: public.tbl_a
  31. $ postgres-execute connection=postgres://postgres:postgres@postgres
  32. ALTER TABLE tbl_a REPLICA IDENTITY FULL
  33. > CREATE TABLE tbl_a FROM SOURCE mz_source (REFERENCE tbl_a);
  34. > SELECT * FROM tbl_a;
  35. 1