From 35241b403f24805e8cc34a4d39bd4c45687831ac Mon Sep 17 00:00:00 2001 From: Sergei Zaychenko Date: Tue, 24 Sep 2024 14:28:13 -0700 Subject: [PATCH] Final corrections to application role function and related images --- images/Makefile | 2 +- images/sqlx-cli-with-migrations/Dockerfile | 3 ++- images/sqlx-cli-with-migrations/Makefile | 2 +- images/sqlx-cli/Dockerfile | 3 +-- migrations/postgres/20240924075552_app_user.sql | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/images/Makefile b/images/Makefile index 524e03c43..a68675ea1 100644 --- a/images/Makefile +++ b/images/Makefile @@ -5,7 +5,7 @@ IMAGE_JUPYTER_TAG = 0.6.3 KAMU_VERSION = $(shell cargo metadata --format-version 1 | jq -r '.packages[] | select( .name == "kamu") | .version') SQLX_VERSION = 0.8.2 -IMAGE_SQLX_TAG = $(SQLX_VERSION)-0 +IMAGE_SQLX_TAG = $(SQLX_VERSION)-1 ################################################################################ diff --git a/images/sqlx-cli-with-migrations/Dockerfile b/images/sqlx-cli-with-migrations/Dockerfile index 14e82a78c..325a01e36 100644 --- a/images/sqlx-cli-with-migrations/Dockerfile +++ b/images/sqlx-cli-with-migrations/Dockerfile @@ -10,7 +10,8 @@ RUN apk --no-cache add \ bash \ curl \ jq \ - aws-cli + aws-cli \ + postgresql-client COPY scripts /scripts RUN chmod -R 0755 /scripts diff --git a/images/sqlx-cli-with-migrations/Makefile b/images/sqlx-cli-with-migrations/Makefile index f1d48ba76..9a488d398 100644 --- a/images/sqlx-cli-with-migrations/Makefile +++ b/images/sqlx-cli-with-migrations/Makefile @@ -6,7 +6,7 @@ ifndef KAMU_VERSION $(error KAMU_VERSION is not set) endif -IMAGE_TAG = $(KAMU_VERSION) +IMAGE_TAG = $(KAMU_VERSION).1 IMAGE_SQLX_TAG = latest ################################################################################ diff --git a/images/sqlx-cli/Dockerfile b/images/sqlx-cli/Dockerfile index 9984e0c36..5597ae84f 100644 --- a/images/sqlx-cli/Dockerfile +++ b/images/sqlx-cli/Dockerfile @@ -10,8 +10,7 @@ ARG VERSION # cargo-binstall: preparation RUN apk add --no-cache \ curl \ - bash \ - postgresql-client + bash # cargo-binstall: install RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash diff --git a/migrations/postgres/20240924075552_app_user.sql b/migrations/postgres/20240924075552_app_user.sql index 005163d6b..ef5f9f372 100644 --- a/migrations/postgres/20240924075552_app_user.sql +++ b/migrations/postgres/20240924075552_app_user.sql @@ -6,7 +6,7 @@ BEGIN -- Check role is not present IF NOT EXISTS (SELECT * FROM pg_roles WHERE rolname = rolename) THEN -- Create role and grant basic access - EXECUTE format('CREATE ROLE %I WITH LOGIN PASSWORD ''%I''', rolename, role_password); + EXECUTE format('CREATE ROLE %I WITH LOGIN PASSWORD ''%s''', rolename, role_password); EXECUTE format('GRANT CONNECT ON DATABASE %I TO %I', db_name, rolename); EXECUTE format('GRANT USAGE ON SCHEMA public TO %I', rolename); -- Privileges for existing objects @@ -15,7 +15,7 @@ BEGIN -- Default privileges (affects future objects) EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO %I', rolename); EXECUTE format('ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT USAGE ON SEQUENCES TO %I', rolename); - RETURN 'CREATE ROLE'; + RETURN format('CREATE ROLE %I', rolename); ELSE -- Role already exists RETURN format('ROLE ''%I'' ALREADY EXISTS', rolename);