DROP TABLE IF EXISTS `gridsetting_tmp`;
CREATE TABLE `gridsetting_tmp` 
	SELECT gst_form, gst_grid, gst_fieldname, gst_title_caption, gst_title_fontsize, gst_data_align, gst_title_fontstyle, gst_data_fontstyle, gst_data_mask, gst_order, gst_width, gst_visible, gst_user, gst_hidden, gst_footer_valuetype
FROM gridsettings
GROUP BY gst_form, gst_grid, gst_fieldname, gst_user
ORDER BY gst_visible DESC, gst_width DESC;

START TRANSACTION;
DELETE FROM `gridsettings`;
COMMIT;

ALTER TABLE `gridsettings`
  DROP COLUMN `gst_comp`,
  DROP INDEX `gst_comp`,
  DROP INDEX `gst_index_col`,
  ADD KEY `gst_index_col` (
    `gst_user`,
    `gst_form`,
    `gst_fieldname`
  ),
  
  ADD UNIQUE INDEX `gst_UNIQUE_KEY` (
    `gst_form`,
    `gst_grid`,
    `gst_fieldname`,
    `gst_user`
  );
  
START TRANSACTION;
INSERT INTO gridsettings (gst_form, gst_grid, gst_fieldname, gst_title_caption, gst_title_fontsize, gst_data_align, gst_title_fontstyle, gst_data_fontstyle, gst_data_mask, gst_order, gst_width, gst_visible, gst_user, gst_hidden, gst_footer_valuetype)
SELECT gst_form, gst_grid, gst_fieldname, gst_title_caption, gst_title_fontsize, gst_data_align, gst_title_fontstyle, gst_data_fontstyle, gst_data_mask, gst_order, gst_width, gst_visible, gst_user, gst_hidden, gst_footer_valuetype
FROM gridsetting_tmp;
COMMIT;

DROP TABLE `gridsetting_tmp`;

ALTER TABLE `dir_goods`
  ADD COLUMN `gd_multiplicity` INT DEFAULT 0 NOT NULL COMMENT 'кратность товара (сколько товара в упаковке)' AFTER `gd_min_quantity`;
COMMIT;


START TRANSACTION;
INSERT INTO dir_users_rights (usrg_id, usrg_name, usrg_value, usrg_order, usrg_group) VALUES (10076, 'Изменять параметры таблиц для других пользователя', 0, 14,34);
UPDATE sys_info SET si_version = "1.562" WHERE sys_info.si_id = 1;
COMMIT; 

