deploy dolibarr
This commit is contained in:
21
chart/scripts/update_ownership.sql
Normal file
21
chart/scripts/update_ownership.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
-- PGPASSWORD=${DOLI_DB_PASSWORD} psql -U ${DOLI_DB_USER} -h ${DOLI_DB_HOST} -p ${DOLI_DB_HOST_PORT} ${DOLI_DB_NAME}
|
||||
DO $$
|
||||
DECLARE
|
||||
current_schema_owner VARCHAR; -- Propriétaire actuel du schéma public
|
||||
BEGIN
|
||||
|
||||
-- Obtenir le nom du propriétaire actuel du schéma 'public'
|
||||
SELECT tableowner INTO current_schema_owner
|
||||
FROM pg_tables
|
||||
WHERE schemaname = 'public'
|
||||
LIMIT 1;
|
||||
|
||||
-- Si le propriétaire actuel est différent de erp_role
|
||||
IF current_schema_owner <> 'erp_role' THEN
|
||||
-- Construire et exécuter la requête REASSIGN OWNED BY
|
||||
EXECUTE format('REASSIGN OWNED BY %I TO %I', current_schema_owner, 'erp_role');
|
||||
RAISE NOTICE 'Ownership of all objects in schema "public" has been reassigned from % to %', current_schema_owner, 'erp_role';
|
||||
ELSE
|
||||
RAISE NOTICE 'No change needed; the owner of schema "public" is already %', 'erp_role';
|
||||
END IF;
|
||||
END $$;
|
||||
Reference in New Issue
Block a user