Skip to content

Commit

Permalink
SNOW-1465711: Add version_initializer callback (#1)
Browse files Browse the repository at this point in the history
* SNOW-1465711: Add version_initializer callback

* Update setup.sql

* Update setup.sql
  • Loading branch information
sfc-gh-osalazarlizano authored Jun 11, 2024
1 parent 4a138a4 commit 99adc82
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions spcs-three-tier/app/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ artifacts:
- /spcs_app/napp/img_repo/eap_backend
- /spcs_app/napp/img_repo/eap_router

lifecycle_callbacks:
version_initializer: v1.init

privileges:
- BIND SERVICE ENDPOINT:
description: "Ability to create ingress URLs."
Expand Down
17 changes: 17 additions & 0 deletions spcs-three-tier/app/setup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@ $$;

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

-- The version initializer callback is executed after a successful installation, upgrade, or downgrade of an application object.
-- In case the application fails to upgrade, the version initializer of the previous (successful) version will be executed so you
-- can clean up application state that may have been modified during the failed upgrade.
CREATE OR REPLACE PROCEDURE v1.init()
RETURNS STRING
LANGUAGE SQL
EXECUTE AS OWNER
AS
$$
BEGIN
ALTER SERVICE IF EXISTS app_public.frontend FROM SPECIFICATION_FILE='frontend.yaml';
ALTER SERVICE IF EXISTS app_public.backend FROM SPECIFICATION_FILE='backend.yaml';
RETURN 'init complete';
END $$;

GRANT USAGE ON PROCEDURE v1.init() TO APPLICATION ROLE app_admin;

CREATE OR REPLACE PROCEDURE v1.start_backend(pool_name VARCHAR)
RETURNS string
LANGUAGE sql
Expand Down

0 comments on commit 99adc82

Please sign in to comment.