2008112001.sql 1.1 KB

123456789101112131415161718192021222324
  1. -- Move plugin settings to private store
  2. INSERT INTO `prefix_private_settings` (entity_guid, name, `value`)
  3. SELECT e.guid as guid, name_string.string as name, value_string.string as `value` FROM `prefix_entities` e
  4. JOIN `prefix_metadata` name_val ON e.guid=name_val.entity_guid
  5. JOIN `prefix_metastrings` name_string ON name_val.name_id = name_string.id
  6. JOIN `prefix_metastrings` value_string ON name_val.value_id = value_string.id
  7. WHERE
  8. e.type='object' AND
  9. e.subtype in (SELECT id from `prefix_entity_subtypes` WHERE subtype='plugin' and type='object');
  10. -- Delete previous settings
  11. CREATE TEMPORARY TABLE __upgrade_2008112001_1 (
  12. SELECT distinct meta.id as id from `prefix_metadata` meta
  13. JOIN `prefix_private_settings` settings ON meta.entity_guid = settings.entity_guid
  14. JOIN `prefix_entities` e ON e.guid = meta.entity_guid
  15. JOIN `prefix_entity_subtypes` subtypes ON subtypes.id = e.subtype
  16. WHERE
  17. e.type='object' AND
  18. subtypes.subtype = 'plugin'
  19. );
  20. DELETE FROM `prefix_metadata` WHERE id in (SELECT id from __upgrade_2008112001_1);
  21. DROP TABLE __upgrade_2008112001_1;