02-create-sources.td 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. $ postgres-execute connection=postgres://mz_system:materialize@${testdrive.materialize-internal-sql-addr}
  10. ALTER SYSTEM SET unsafe_enable_unorchestrated_cluster_replicas = true
  11. > DROP SOURCE IF EXISTS mz_source CASCADE;
  12. > DROP SECRET IF EXISTS pgpass CASCADE;
  13. > DROP CONNECTION IF EXISTS pg CASCADE;
  14. > CREATE CLUSTER storage REPLICAS (
  15. r1 (
  16. STORAGECTL ADDRESSES ['clusterd1:2100'],
  17. STORAGE ADDRESSES ['clusterd1:2103'],
  18. COMPUTECTL ADDRESSES ['clusterd1:2101'],
  19. COMPUTE ADDRESSES ['clusterd1:2102'],
  20. WORKERS 4
  21. )
  22. )
  23. > CREATE SECRET pgpass AS 'postgres'
  24. > CREATE CONNECTION pg TO POSTGRES (
  25. HOST postgres,
  26. DATABASE postgres,
  27. USER postgres,
  28. PASSWORD SECRET pgpass
  29. )
  30. > CREATE SOURCE mz_source
  31. IN CLUSTER storage
  32. FROM POSTGRES
  33. CONNECTION pg
  34. (PUBLICATION 'mz_source');
  35. > CREATE TABLE ten FROM SOURCE mz_source (REFERENCE ten);
  36. > CREATE TABLE t1 FROM SOURCE mz_source (REFERENCE t1);