Skip to content

Commit 99adc82

Browse files
SNOW-1465711: Add version_initializer callback (snowflakedb#1)
* SNOW-1465711: Add version_initializer callback * Update setup.sql * Update setup.sql
1 parent 4a138a4 commit 99adc82

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

spcs-three-tier/app/manifest.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ artifacts:
1919
- /spcs_app/napp/img_repo/eap_backend
2020
- /spcs_app/napp/img_repo/eap_router
2121

22+
lifecycle_callbacks:
23+
version_initializer: v1.init
24+
2225
privileges:
2326
- BIND SERVICE ENDPOINT:
2427
description: "Ability to create ingress URLs."

spcs-three-tier/app/setup.sql

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,23 @@ $$;
4949

5050
GRANT USAGE ON PROCEDURE v1.get_configuration(STRING) TO APPLICATION ROLE app_admin;
5151

52+
-- The version initializer callback is executed after a successful installation, upgrade, or downgrade of an application object.
53+
-- In case the application fails to upgrade, the version initializer of the previous (successful) version will be executed so you
54+
-- can clean up application state that may have been modified during the failed upgrade.
55+
CREATE OR REPLACE PROCEDURE v1.init()
56+
RETURNS STRING
57+
LANGUAGE SQL
58+
EXECUTE AS OWNER
59+
AS
60+
$$
61+
BEGIN
62+
ALTER SERVICE IF EXISTS app_public.frontend FROM SPECIFICATION_FILE='frontend.yaml';
63+
ALTER SERVICE IF EXISTS app_public.backend FROM SPECIFICATION_FILE='backend.yaml';
64+
RETURN 'init complete';
65+
END $$;
66+
67+
GRANT USAGE ON PROCEDURE v1.init() TO APPLICATION ROLE app_admin;
68+
5269
CREATE OR REPLACE PROCEDURE v1.start_backend(pool_name VARCHAR)
5370
RETURNS string
5471
LANGUAGE sql

0 commit comments

Comments
 (0)