Create a New Warehouse #
Before starting, ensure that a warehouse is available in your current connection. If not, create a new warehouse using the following SQL command:
CREATE WAREHOUSE IF NOT EXISTS edna_consumer_warehouse;
Important pre installation step #
As a best practice the application should be installed with a role. The Snowflake Administrator using the AccountAdmin role should execute the following SQL
Switch to the ACCOUNTADMIN role: #
USE ROLE ACCOUNTADMIN;
CREATE ROLE IF NOT EXISTS EDNA_APPS_CONSUMER_ROLE;
GRANT CREATE DATABASE ON ACCOUNT TO ROLE EDNA_APPS_CONSUMER_ROLE;
GRANT CREATE WAREHOUSE ON ACCOUNT TO ROLE EDNA_APPS_CONSUMER_ROLE;
GRANT CREATE COMPUTE POOL ON ACCOUNT TO ROLE EDNA_APPS_CONSUMER_ROLE;
GRANT CREATE INTEGRATION ON ACCOUNT TO ROLE EDNA_APPS_CONSUMER_ROLE;
GRANT CREATE APPLICATION ON ACCOUNT TO ROLE EDNA_APPS_CONSUMER_ROLE ;
GRANT IMPORT SHARE ON ACCOUNT TO EDNA_APPS_CONSUMER_ROLE;
GRANT CREATE SHARE ON ACCOUNT TO EDNA_APPS_CONSUMER_ROLE;
GRANT MANAGE EVENT SHARING ON ACCOUNT TO EDNA_APPS_CONSUMER_ROLE;
GRANT BIND SERVICE ENDPOINT ON ACCOUNT TO ROLE EDNA_APPS_CONSUMER_ROLE WITH GRANT OPTION;
GRANT ROLE EDNA_APPS_CONSUMER_ROLE to USER <add-usernames>; -- or add to existing role
Prepare objects in account #
Execute the following commands with the ACCOUNTADMIN role to set up the necessary database, schema, table, and view that will be used in the application.
Create the database and schema: #
CREATE DATABASE IF NOT EXISTS EDNA_APP_CONSUMER_DB;
CREATE SCHEMA IF NOT EXISTS EDNA_APP_CONSUMER_DB.DATA;
Create the view for ACCOUNT_USERS: #
CREATE VIEW IF NOT EXISTS EDNA_APP_CONSUMER_DB.DATA.ACCOUNT_USERS AS
SELECT FIRST_NAME, LAST_NAME, EMAIL, LOGIN_NAME
FROM SNOWFLAKE.ACCOUNT_USAGE.USERS
WHERE DELETED_ON IS NULL
AND LOGIN_NAME NOT LIKE 'SF$%'
AND NAME <> 'SNOWFLAKE';
Create the table for EDNA_APP_URL: #
CREATE TABLE IF NOT EXISTS EDNA_APP_CONSUMER_DB.DATA.EDNA_APP_URL(
APP_URL VARCHAR,
APP_NAME VARCHAR
);
Note: #
Objects with references are created within stored procedures in the setup_script.sql, not inside user-defined functions (UDFs), as UDFs resolve references only at build-time.