01-build.sql 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 OR REPLACE VIEW v_most_recent_build AS
  10. SELECT
  11. b.branch,
  12. b.pipeline,
  13. max(b.build_number) AS highest_build_number
  14. FROM build b
  15. GROUP BY
  16. b.branch,
  17. b.pipeline
  18. ;
  19. CREATE OR REPLACE VIEW v_branch_type AS
  20. WITH data AS
  21. (
  22. SELECT
  23. b.branch,
  24. (b.branch = 'main') AS is_main_branch,
  25. (b.branch LIKE 'v%.%.%') AS is_release_branch,
  26. (b.branch <> 'main' AND b.branch NOT LIKE 'v%.%.%') AS is_feature_branch
  27. FROM build b
  28. GROUP BY
  29. b.branch
  30. )
  31. SELECT
  32. branch,
  33. CASE WHEN is_main_branch THEN 'main' WHEN is_release_branch THEN 'release' WHEN is_feature_branch THEN 'feature' ELSE '?' END AS branch_type,
  34. is_main_branch,
  35. is_release_branch,
  36. is_feature_branch
  37. FROM data
  38. ;
  39. ALTER VIEW v_most_recent_build OWNER TO qa;
  40. ALTER VIEW v_branch_type OWNER TO qa;