Hi all,
Looking for some advice on how to do this.
I'm on v25.1.1 (can't update until I pack up the current release)
To add the column, i did these steps:
- add the column without the not null constraint
- disable my audit trigger, so my audit values are not polluted
- update all the records in the table
- add the not null constraint
- re-enable the audit trigger
I've used the following script:
alter table damage_pictures add (pic_guid raw(16));
alter trigger dap_rbiu_audit disable;
begin
for r in (select * from damage_pictures order by picture_id asc)
loop
update damage_pictures
set pic_guid = dbms_crypto.randombytes(16)
where damage_picture_id = r.damage_picture_id;
end loop;
end;
/
alter table damage_pictures modify (pic guid not null enable);
alter trigger dap_rbiu_audit enable;
Now, of course, when doing a project export, the damage_pictures.sql picks up the new column and the not null constraint. Project has no knowledge of this nuance so of course, how could the staging.
Is my only option to atomize these changes into several "stages"? eg:
- create a stage for the column addition, add custom sql to disable the trigger, fill the column, enable the trigger
- create a stage for the not null constraint
Just checking if there are other ways, since this is a really really small change as part of a bigger development with changes in views, packages and apex. Ideally I won't need to atomize every small change, and maybe this is an exception.
(Feeding into another/next question, do I need to create multiple releases to go with these changes/stages? Which I also splitted off to another thread)