Legacy database scripts for Survey and Vote macros

Please note that this is legacy documentation and meant to be informational only. Database updates are not 'supported' operations at this time.

Introduction

Before you run any SQL scripts to modify content directly, please be aware that you must invalidate the internal caches or the Application will not behave normal! 
All Scripts stated here are tested on MySQL Databases

How to invalidate caches

  • in the administration section go to Cache Statistics
  • Click Flush All (this works, i cant tell you right now which cache would be affected otherwise)

current survey and vote scripts

Remove votes of a specific page

--entity_id is the id of the page the vote is stored on (e.g. 557062)
--This will remove ALL votes on the given wiki page. Not just the single vote you may be looking for.
delete from OS_PROPERTYENTRY where entity_id=<somePageId> and entity_key like 'vote.%';

Legacy Database Scripts

Migration Scripts for Survey-Plugin 1.0 or the Vote Plugin to 1.1 and later

Due to the necessary change of saving data to the text-field in 1.1.* you have to update your old data in the database accordingly. See the MySQL-Command samples here:

--this will change the value and type from string to text
update os_propertyentry set key_type=6, text_val=string_val where entity_key like 'vote.%' --this nulls the old stringvals update os_propertyentry set string_val=null where entity_key like 'vote.%' --comments handling: --this will change the value and type from string to text update os_propertyentry set key_type=6, text_val=string_val where entity_key like 'survey.%.commenters';

--this nulls the old stringvals
update os_propertyentry set string_val=null where entity_key like 'survey.%.commenters';

If you cant see some old values, maybe you have some unnecessary Html-Tags in your data, try (under MySQL):

--this will cut the occurance on the right of the html tag </p>
update os_propertyentry set entity_key=left(entity_key,length(entity_key)-4) where entity_key like 'vote.%' and right(entity_key,4)='</p>' --this will cut the occurance on the right of the html tag <br/> update os_propertyentry set entity_key=left(entity_key,length(entity_key)-5) where entity_key like 'vote.%' and right(entity_key,5)='<br/>' --this will cut the occurance of the html tag <p> which can occur within the vote-saved string update os_propertyentry set entity_key=REPLACE(entity_key,'<p>','') where entity_key like 'vote.%<p>%'

Select Samples

Here is a sample of a select statement of a PostgreSQL Database:

select * from OS_PROPERTYENTRY where entity_key like 'vote.%';:

entity_name;entity_id;entity_key;key_type;boolean_val;double_val;string_val;text_val;long_val;int_val;date_val
"confluence_ContentEntityObject";720900;"vote.tralala.3-Satisfactory";6;f;0;"";"";0;0;""
"confluence_ContentEntityObject";720900;"vote.tralala.4-More Than Satisfactory";6;f;0;"";"";0;0;""
"confluence_ContentEntityObject";720900;"vote.tralala.5-Outstanding";6;f;0;"";"";0;0;""
"confluence_ContentEntityObject";720900;"vote.tralala.2-Less Than Satisfactory";6;f;0;"";"admin";0;0;""

This means that in this instance i just had one Wiki Page (with id 720900) where one user (admin) voted on a vote with a option of 2-Less Than Satisfactory