01-setup.td 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. $ http-request method=POST url=http://toxiproxy:8474/proxies content-type=application/json
  10. {
  11. "name": "postgres",
  12. "listen": "0.0.0.0:5432",
  13. "upstream": "postgres:5432",
  14. "enabled": true
  15. }
  16. > CREATE SECRET pgpass AS 'postgres'
  17. > CREATE CONNECTION pg TO POSTGRES (
  18. HOST toxiproxy,
  19. DATABASE postgres,
  20. USER postgres,
  21. PASSWORD SECRET pgpass
  22. )
  23. $ postgres-execute connection=postgres://postgres:postgres@postgres
  24. ALTER USER postgres WITH replication;
  25. DROP SCHEMA IF EXISTS public CASCADE;
  26. CREATE SCHEMA public;
  27. DROP PUBLICATION IF EXISTS mz_source;
  28. CREATE PUBLICATION mz_source FOR ALL TABLES;
  29. CREATE TABLE t (a int);
  30. INSERT INTO t VALUES (1);
  31. ALTER TABLE t REPLICA IDENTITY FULL;
  32. > CREATE SOURCE pg_source
  33. FROM POSTGRES CONNECTION pg (PUBLICATION 'mz_source')
  34. FOR TABLES ("t");
  35. > SELECT * FROM t;
  36. 1
  37. $ postgres-execute connection=postgres://postgres:postgres@postgres
  38. ALTER TABLE t DROP COLUMN a;
  39. ALTER TABLE t ADD COLUMN a int;
  40. INSERT INTO t VALUES (2);
  41. > SELECT name, status FROM mz_internal.mz_source_statuses;
  42. pg_source running
  43. pg_source_progress running
  44. t ceased
  45. > SELECT
  46. status = 'ceased'
  47. AND
  48. error ILIKE '%incompatible schema change%'
  49. FROM mz_internal.mz_source_statuses
  50. WHERE name = 't';
  51. true
  52. ! SELECT * FROM t;
  53. contains: incompatible schema change