Skip to content

Commit

Permalink
Photo-related upgrade script for MySQL.
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Sep 29, 2015
1 parent d1caa98 commit 474fb14
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions config/sql/_all/mysql-upgrade-3.2-3.3.sql
Expand Up @@ -17,6 +17,21 @@ alter table m_sequence

rename table m_user_photo to m_focus_photo;

alter table m_focus add hasPhoto bit not null after validityStatus;
alter table m_focus add hasPhoto bit not null default 0;

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 alter column hasPhoto drop default;

alter table m_user drop column hasPhoto;

alter table m_focus_photo
drop foreign key fk_user_photo;

alter table m_focus_photo
add constraint fk_focus_photo
foreign key (owner_oid)
references m_focus (oid);

alter table m_user drop hasPhoto;

0 comments on commit 474fb14

Please sign in to comment.