Skip to content

Commit

Permalink
Photo-related upgrade script for Oracle & H2.
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Sep 29, 2015
1 parent 474fb14 commit 3861017
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
18 changes: 15 additions & 3 deletions config/sql/_all/h2-upgrade-3.2-3.3.sql
Expand Up @@ -14,7 +14,7 @@ alter table m_sequence
references m_object;

alter table m_user_photo
drop constraint fk_user_photo;
drop constraint fk_user_photo;

alter table m_user_photo rename to m_focus_photo;

Expand All @@ -23,6 +23,18 @@ alter table m_focus_photo
foreign key (owner_oid)
references m_focus;

alter table m_focus add hasPhoto bit not null after validityStatus;

alter table m_user drop hasPhoto;
alter table m_focus add hasPhoto boolean not null default false after validityStatus;

update m_focus set hasPhoto = false;
update m_focus set hasPhoto = (select hasPhoto from m_user where m_user.oid = m_focus.oid)
where m_focus.oid in (select oid from m_user);

-- don't know how to drop default value, leaving it there

alter table m_user drop column hasPhoto;





16 changes: 15 additions & 1 deletion config/sql/_all/oracle-upgrade-3.2-3.3.sql
Expand Up @@ -13,8 +13,22 @@ alter table m_sequence
foreign key (oid)
references m_object;



alter table m_user_photo
drop constraint fk_user_photo;

rename m_user_photo to m_focus_photo;

alter table m_focus add hasPhoto bit not null;
alter table m_focus_photo
add constraint fk_focus_photo
foreign key (owner_oid)
references m_focus;

alter table m_focus add hasPhoto number(1,0) default 0 not null;
update m_focus set hasPhoto = 0;
update m_focus set hasPhoto = (select hasPhoto from m_user where m_user.oid = m_focus.oid)
where m_focus.oid in (select oid from m_user);
alter table m_focus modify hasPhoto default null;

alter table m_user drop column hasPhoto;

0 comments on commit 3861017

Please sign in to comment.