2009-08-21 19:51:56 +04:00
|
|
|
|
-- SQL скрипт изменений требуемых в нашей боевой базе багзиллы при обновлении с 2.x до 3.х
|
|
|
|
|
-- Возможно, добавятся ещё новые кривости, но пока так.
|
2009-08-04 23:01:33 +04:00
|
|
|
|
set names utf8;
|
2009-08-21 19:51:56 +04:00
|
|
|
|
-- ДО ./checksetup.pl:
|
2009-08-18 16:08:16 +04:00
|
|
|
|
alter table components change wiki_url wiki_url1 varchar(255) not null;
|
2009-08-21 19:51:56 +04:00
|
|
|
|
-- ПОСЛЕ ./checksetup.pl:
|
2009-08-18 16:08:16 +04:00
|
|
|
|
alter table components drop wiki_url;
|
|
|
|
|
alter table components change wiki_url1 wiki_url varchar(255) not null;
|
2009-08-21 19:51:56 +04:00
|
|
|
|
-- Убираем старые юзерские настройки
|
2009-08-25 21:42:56 +04:00
|
|
|
|
create temporary table tmp2 as select user_id, 'post_bug_submit_action' AS setting_name, (case when setting_value='on' then 'next_bug' else 'same_bug' end) as setting_value from profile_setting where setting_name='go_to_next_bug';
|
2009-08-25 21:40:41 +04:00
|
|
|
|
replace into profile_setting (user_id, setting_name, setting_value) select * from tmp2;
|
|
|
|
|
drop table tmp2;
|
2009-08-28 20:15:49 +04:00
|
|
|
|
delete from profile_setting where setting_name in ('go_to_next_bug', 'remind_me_about_flags', 'create_bug_resolved', 'create_bug_assigned');
|
2009-08-25 21:40:41 +04:00
|
|
|
|
update profile_setting set setting_name='remind_me_about_flags' where setting_name='remind_me_about_requests';
|
2009-08-28 20:15:49 +04:00
|
|
|
|
delete from setting_value where name in ('go_to_next_bug', 'remind_me_about_requests', 'create_bug_resolved', 'create_bug_assigned');
|
|
|
|
|
delete from setting where name in ('go_to_next_bug', 'remind_me_about_requests', 'create_bug_resolved', 'create_bug_assigned');
|
2009-08-21 19:51:56 +04:00
|
|
|
|
-- Дальше ДОЛЖНО уже быть создано поле cf_agreement (договор) зависимое от продукта
|
|
|
|
|
-- Наполняем значениями поле "Договор"
|
2009-08-19 20:16:31 +04:00
|
|
|
|
insert into cf_agreement (value, sortkey, isactive, visibility_value_id)
|
|
|
|
|
select name, sortkey, act, (case when count(`name`) > 1 then NULL else `vis` end)
|
|
|
|
|
from (
|
|
|
|
|
select
|
|
|
|
|
(case when instr(name,' (') > 0 then substr(`name`,1,instr(name,' (')-1) else `name` end) as `name`,
|
|
|
|
|
sortkey,
|
|
|
|
|
1 as act,
|
|
|
|
|
product_id as vis
|
|
|
|
|
from agreements
|
2009-08-21 19:51:56 +04:00
|
|
|
|
where name not in ('!Без договора', '--', '---', '--- пусто', 'Unspec')
|
2009-08-19 20:16:31 +04:00
|
|
|
|
) as `t0`
|
|
|
|
|
group by (case when instr(name,' (') > 0 then substr(`name`,1,instr(name,' (')-1) else `name` end);
|
2009-08-21 19:51:56 +04:00
|
|
|
|
-- Устанавливаем правильные sortkey, такие, чтобы ограниченные значения были вверху,
|
2009-08-19 20:16:31 +04:00
|
|
|
|
create temporary table tmp1 (id int not null auto_increment primary key, sortkey int not null default 0);
|
|
|
|
|
insert into tmp1 (sortkey) select distinct sortkey from cf_agreement where visibility_value_id IS NOT NULL order by sortkey;
|
|
|
|
|
update cf_agreement set sortkey=5+5*(select tmp1.id from tmp1 where tmp1.sortkey=cf_agreement.sortkey) where visibility_value_id IS NOT NULL;
|
|
|
|
|
drop table tmp1;
|
2009-08-21 19:51:56 +04:00
|
|
|
|
-- А неограниченные - внизу
|
2009-08-19 20:16:31 +04:00
|
|
|
|
create temporary table tmp1 (id int not null auto_increment primary key, sortkey int not null default 0);
|
|
|
|
|
insert into tmp1 (sortkey) select distinct sortkey from cf_agreement where visibility_value_id IS NULL order by sortkey;
|
|
|
|
|
update cf_agreement set sortkey=200+5*(select tmp1.id from tmp1 where tmp1.sortkey=cf_agreement.sortkey) where visibility_value_id IS NULL;
|
|
|
|
|
drop table tmp1;
|
2009-08-28 01:26:24 +04:00
|
|
|
|
-- А --- между ними
|
|
|
|
|
update cf_agreement set sortkey=195 where value='---';
|
2009-08-21 19:51:56 +04:00
|
|
|
|
-- Записываем значения договора для всех багов
|
2009-08-19 20:16:31 +04:00
|
|
|
|
update bugs, agreements, cf_agreement
|
|
|
|
|
set bugs.cf_agreement=(case when instr(agreements.name,' (') > 0 then substr(agreements.`name`,1,instr(agreements.name,' (')-1) else agreements.`name` end)
|
|
|
|
|
where bugs.agreement_id=agreements.id
|
2009-08-21 19:51:56 +04:00
|
|
|
|
and agreements.name not in ('!Без договора', '--', '---', '--- пусто', 'Unspec');
|
|
|
|
|
-- Удаляем старое поле "agreement" из fielddefs
|
2009-08-19 22:22:33 +04:00
|
|
|
|
update bugs_activity set fieldid=(select fielddefs.id from fielddefs where fielddefs.name='cf_agreement') where fieldid=(select fielddefs.id from fielddefs where fielddefs.name='agreement');
|
|
|
|
|
delete from fielddefs where name='agreement';
|