before-restart.td 1.4 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. > CREATE SECRET mysqlpass AS '${arg.mysql-root-password}'
  10. > CREATE CONNECTION mysq TO MYSQL (
  11. HOST mysql,
  12. USER root,
  13. PASSWORD SECRET mysqlpass
  14. )
  15. $ mysql-connect name=mysql url=mysql://root@mysql password=${arg.mysql-root-password}
  16. # Create some test tables
  17. # Insert a bunch of rows one of the tables so the snapshot doesn't complete before we restart MZ
  18. $ mysql-execute name=mysql
  19. DROP DATABASE IF EXISTS public;
  20. CREATE DATABASE public;
  21. USE public;
  22. CREATE TABLE dummy (f1 INTEGER, f2 INTEGER);
  23. SET @i:=0;
  24. INSERT INTO dummy (f1, f2) SELECT @i:=@i+1, FLOOR(RAND()*10000) FROM mysql.time_zone t1, mysql.time_zone t2 LIMIT 50000;
  25. CREATE TABLE other (d1 INTEGER);
  26. INSERT INTO other VALUES (1), (2), (3);
  27. > CREATE SOURCE schema_test FROM MYSQL CONNECTION mysq;
  28. > CREATE TABLE dummy FROM SOURCE schema_test (REFERENCE public.dummy);
  29. > CREATE TABLE other FROM SOURCE schema_test (REFERENCE public.other);
  30. # Now alter the dummy table
  31. $ mysql-execute name=mysql
  32. USE public;
  33. ALTER TABLE dummy DROP COLUMN f2;
  34. # Now restart MZ