Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop table inheritance for *_notes and *_translations tables #8656

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions sql/changes/1.13/drop-inheritance-notes-translations.sql
Original file line number Diff line number Diff line change
@@ -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";
1 change: 1 addition & 0 deletions sql/changes/LOADORDER
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions sql/modules/Assets.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions sql/modules/Budgetting.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sql/modules/Company.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions sql/modules/Roles.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions xt/42-company.pg
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down
Loading