2008112002.sql 1.2 KB

1234567891011121314151617181920212223242526272829
  1. -- Move user plugins settings to new data 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='user' AND
  9. name_string.string like 'plugin:settings:%';
  10. -- Delete previous settings
  11. CREATE TEMPORARY TABLE __upgrade_2008112002_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_metadata` name_val ON e.guid=name_val.entity_guid
  16. JOIN `prefix_metastrings` name_string ON name_val.name_id = name_string.id
  17. JOIN `prefix_metastrings` value_string ON name_val.value_id = value_string.id
  18. WHERE
  19. e.type='user' AND
  20. name_string.string like 'plugin:settings:%' AND
  21. meta.name_id = name_string.id
  22. );
  23. DELETE FROM `prefix_metadata` WHERE id in (SELECT id from __upgrade_2008112002_1);
  24. DROP TABLE __upgrade_2008112002_1;