diff --git a/sql/changes/1.13/drop-inheritance-notes-translations.sql b/sql/changes/1.13/drop-inheritance-notes-translations.sql new file mode 100644 index 0000000000..d8cbf79538 --- /dev/null +++ b/sql/changes/1.13/drop-inheritance-notes-translations.sql @@ -0,0 +1,55 @@ + +alter table asset_note no inherit note; +alter table asset_note + alter column id drop default, + alter column id add generated always as identity; +alter table budget_note no inherit note; +alter table budget_note + alter column id drop default, + alter column id add generated always as identity; +alter table eca_note no inherit note; +alter table eca_note + alter column id drop default, + alter column id add generated always as identity; +alter table entity_note no inherit note; +alter table entity_note + alter column id drop default, + alter column id add generated always as identity; +alter table invoice_note no inherit note; +alter table invoice_note + alter column id drop default, + alter column id add generated always as identity; +alter table journal_note no inherit note; +alter table journal_note + alter column id drop default, + alter column id add generated always as identity; + +select setval('asset_note_id_seq', + coalesce((select max(id) from asset_note) + 1, 1), + false); +select setval('budget_note_id_seq', + coalesce((select max(id) from budget_note) + 1, 1), + false); +select setval('eca_note_id_seq', + coalesce((select max(id) from eca_note) + 1, 1), + false); +select setval('entity_note_id_seq', + coalesce((select max(id) from entity_note) + 1, 1), + false); +select setval('invoice_note_id_seq', + coalesce((select max(id) from invoice_note) + 1, 1), + false); +select setval('journal_note_id_seq', + coalesce((select max(id) from journal_note) + 1, 1), + false); + + +drop table note; + +alter table account_heading_translation no inherit "translation"; +alter table account_translation no inherit "translation"; +alter table business_unit_translation no inherit "translation"; +alter table parts_translation no inherit "translation"; +alter table partsgroup_translation no inherit "translation"; + +drop table "translation"; diff --git a/sql/changes/LOADORDER b/sql/changes/LOADORDER index 39efadbf04..2bdca2c9cc 100644 --- a/sql/changes/LOADORDER +++ b/sql/changes/LOADORDER @@ -197,3 +197,4 @@ mc/delete-migration-validation-data.sql 1.13/change-logout.sql 1.13/rm-status.sql 1.13/fk-actions-for-is_used-functions.sql +1.13/drop-inheritance-notes-translations.sql \ No newline at end of file diff --git a/sql/modules/Assets.sql b/sql/modules/Assets.sql index 0328b7d83c..461731d205 100644 --- a/sql/modules/Assets.sql +++ b/sql/modules/Assets.sql @@ -877,8 +877,8 @@ CREATE OR REPLACE FUNCTION asset_item__add_note(in_id int, in_subject text, in_n RETURNS asset_note AS $$ INSERT INTO asset_note (ref_key, subject, note) - values (in_id, in_subject, in_note); -SELECT * FROM asset_note WHERE id = currval('note_id_seq'); + values (in_id, in_subject, in_note) +RETURNING *; $$ language sql; COMMENT ON FUNCTION asset_item__add_note(in_id int, in_subject text, diff --git a/sql/modules/Budgetting.sql b/sql/modules/Budgetting.sql index e7a9ef8f90..5a0e2fb948 100644 --- a/sql/modules/Budgetting.sql +++ b/sql/modules/Budgetting.sql @@ -243,9 +243,8 @@ CREATE OR REPLACE FUNCTION budget__save_note RETURNS budget_note AS $$ INSERT INTO budget_note (subject, note, ref_key) - values ($2, $3, $1); - -SELECT * FROM budget_note WHERE id = currval('note_id_seq'::regclass); + values ($2, $3, $1) +RETURNING *; $$ language sql; COMMENT ON FUNCTION budget__save_note diff --git a/sql/modules/Company.sql b/sql/modules/Company.sql index 9cae1d8470..2aeeb93d3e 100644 --- a/sql/modules/Company.sql +++ b/sql/modules/Company.sql @@ -1098,7 +1098,7 @@ COMMENT ON FUNCTION entity__list_notes(in_entity_id int) IS $$ Returns a set of notes (including content) attached to the entity.$$; CREATE OR REPLACE FUNCTION eca__list_notes(in_credit_id int) -RETURNS SETOF note AS +RETURNS SETOF eca_note AS $$ DECLARE out_row record; t_entity_id int; diff --git a/sql/modules/Roles.sql b/sql/modules/Roles.sql index 59e0ba9dc2..799362a839 100644 --- a/sql/modules/Roles.sql +++ b/sql/modules/Roles.sql @@ -515,7 +515,8 @@ SELECT lsmb__grant_perms('contact_create', 'person', 'INSERT'); SELECT lsmb__grant_perms('contact_create', 'person_id_seq', 'ALL'); SELECT lsmb__grant_perms('contact_create', 'entity_credit_account', 'INSERT'); SELECT lsmb__grant_perms('contact_create', 'entity_credit_account_id_seq', 'ALL'); -SELECT lsmb__grant_perms('contact_create', 'note_id_seq', 'ALL'); +SELECT lsmb__grant_perms('contact_create', 'entity_note_id_seq', 'ALL'); +SELECT lsmb__grant_perms('contact_create', 'eca_note_id_seq', 'ALL'); SELECT lsmb__grant_perms('contact_create', 'entity_bank_account', 'INSERT'); SELECT lsmb__grant_perms('contact_create', 'entity_bank_account_id_seq', 'ALL'); SELECT lsmb__grant_perms('contact_create', 'entity_to_location', 'INSERT'); @@ -1960,7 +1961,7 @@ SELECT lsmb__grant_perms('base_user', obj, 'SELECT') FROM unnest(array['user_listable'::text, 'language', 'menu_node', 'menu_acl', 'gifi', 'country', 'taxmodule', - 'parts', 'partsgroup', 'country_tax_form', 'translation', + 'parts', 'partsgroup', 'country_tax_form', 'business', 'template', --###TODO: Add table for advisory rates --'exchangerate', diff --git a/xt/42-company.pg b/xt/42-company.pg index 438785ac68..032fc19500 100644 --- a/xt/42-company.pg +++ b/xt/42-company.pg @@ -132,7 +132,7 @@ BEGIN; PREPARE test AS SELECT CASE WHEN subject = 'Test note subject' THEN 't'::bool ELSE 'f'::bool END FROM entity_note - WHERE id = currval('note_id_seq'); + WHERE id = currval('entity_note_id_seq'); SELECT results_eq('test',ARRAY[true],'entity__save_note subject record'); DEALLOCATE test; @@ -144,7 +144,7 @@ BEGIN; PREPARE test AS SELECT CASE WHEN subject = 'ECA test note subject' THEN 't'::bool ELSE 'f'::bool END FROM eca_note - WHERE id = currval('note_id_seq'); + WHERE id = currval('eca_note_id_seq'); SELECT results_eq('test',ARRAY[true],'eca__save_notes subject record'); DEALLOCATE test;