Skip to content

Commit

Permalink
Merge f143479 into 2a79d5a
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuelsmann committed May 28, 2023
2 parents 2a79d5a + f143479 commit 81f8ee3
Show file tree
Hide file tree
Showing 5 changed files with 787 additions and 162 deletions.
4 changes: 2 additions & 2 deletions lib/LedgerSMB/Admin/Command/user.pm
Expand Up @@ -555,7 +555,7 @@ Permission(s) to affect to the user.
Permission can be C<Full Permissions> or a comma separated list of the following roles:
C<account_all> C<account_create> C<account_delete> C<account_edit> C<account_link_description_create>
C<ap_all> C<ap_all_transactions> C<ap_all_vouchers> C<ap_invoice_create> C<ap_invoice_create_voucher>
C<ap_all> C<ap_voucher_all> C<ap_invoice_create> C<ap_invoice_create_voucher>
C<ap_transaction_all> C<ap_transaction_create> C<ap_transaction_create_voucher> C<ap_transaction_list>
C<ar_all> C<ar_invoice_create> C<ar_invoice_create_voucher> C<ar_transaction_all> C<ar_transaction_create>
C<ar_transaction_create_voucher> C<ar_transaction_list> C<ar_voucher_all> C<assembly_stock>
Expand All @@ -579,7 +579,7 @@ C<sales_order_edit> C<sales_order_list> C<sales_quotation_create> C<sales_quotat
C<sic_create> C<sic_edit> C<system_admin> C<system_settings_change> C<system_settings_list>
C<tax_form_save> C<taxes_set> C<template_edit> C<timecard_add> C<timecard_list> C<timecard_order_generate>
C<transaction_template_delete> C<translation_create> C<users_manage> C<voucher_delete> C<warehouse_create>
C<warehouse_edit> C<yearend_reopen> C<yearend_run> C<yearend_run>
C<warehouse_edit> C<yearend_reopen> C<yearend_run> C<yearend_run>
=item ssn C<string>
Expand Down
26 changes: 26 additions & 0 deletions sql/changes/1.11/ar-ap-role-naming-consistency.sql
@@ -0,0 +1,26 @@

-- Define a function which will be dropped after the session ends
CREATE FUNCTION pg_temp.lsmb__role(global_role text) RETURNS text
LANGUAGE SQL STABLE AS
$$ select coalesce((select value
from defaults
where setting_key = 'role_prefix'),
'lsmb_' || current_database() || '__') || global_role; $$;

DO $$
DECLARE
t_rolename text;
BEGIN
select pg_temp.lsmb__role('ap_all_vouchers') into t_rolename;
perform * from pg_roles where rolname = t_rolename;
if found then
execute 'alter role ' || quote_ident(t_rolename) || ' rename to ' || quote_ident(pg_temp.lsmb__role('ap_voucher_all'));
end if;

-- drop a role which doesn't have an AR equivalent and from its naming
-- is at least confusing...
select pg_temp.lsmb__role('ap_all_transactions') into t_rolename;
execute 'drop role if exists ' || quote_ident(t_rolename);
END;
$$ language plpgsql;

1 change: 1 addition & 0 deletions sql/changes/LOADORDER
Expand Up @@ -178,3 +178,4 @@ mc/delete-migration-validation-data.sql
1.11/reversed-transactions.sql
1.11/negative-assets-liablilities-reclass.sql
1.11/rm-aa-entity_id.sql
1.11/ar-ap-role-naming-consistency.sql

0 comments on commit 81f8ee3

Please sign in to comment.