schemas.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. from textwrap import dedent
  10. from materialize.checks.actions import Testdrive
  11. from materialize.checks.checks import Check
  12. class CheckSchemas(Check):
  13. def manipulate(self) -> list[Testdrive]:
  14. return [
  15. Testdrive(dedent(s))
  16. for s in [
  17. """
  18. > CREATE SCHEMA to_be_created;
  19. > CREATE SCHEMA to_be_dropped;
  20. > CREATE TABLE to_be_dropped.t1 (f1 INTEGER);
  21. """,
  22. """
  23. > DROP SCHEMA to_be_dropped CASCADE;
  24. """,
  25. ]
  26. ]
  27. def validate(self) -> Testdrive:
  28. return Testdrive(
  29. dedent(
  30. """
  31. > SHOW SCHEMAS LIKE 'to_be_%';
  32. to_be_created ""
  33. """
  34. )
  35. )