Skip to content

Commit

Permalink
Photo-related upgrade script for PostgreSQL.
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Sep 29, 2015
1 parent 5fd41bf commit ac3ab49
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion config/sql/_all/postgresql-upgrade-3.2-3.3.sql
Expand Up @@ -15,6 +15,24 @@ alter table m_sequence

alter table m_user_photo rename to m_focus_photo;

alter table m_focus add hasPhoto bit not null;
alter table m_focus add hasPhoto boolean not null default FALSE;
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);
alter table m_focus alter column hasPhoto drop default;

alter table m_focus_photo
drop constraint m_user_photo_pkey;

alter table m_focus_photo
add constraint m_focus_photo_pkey primary key(owner_oid);

alter table m_focus_photo
drop constraint fk_user_photo;

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

alter table m_user drop column hasPhoto;

0 comments on commit ac3ab49

Please sign in to comment.