DROP CONSTRAINT ON (page:Page) ASSERT page.pageId IS UNIQUE;

//Remove all blogs
MATCH (:User)-[written:WRITTEN]->(b:Blog)
OPTIONAL MATCH (b)<-[rel]-(recommendation:Recommendation)<-[rel2:RECOMMENDS]-(:User)
DELETE written, rel, rel2, b, recommendation;

//Set Answer label
MATCH (b:Page)
SET b:Answer
SET b.answerId = b.pageId
REMOVE b.pageId;

//Page with generic label to Organisation
MATCH (b:Page)
WHERE b.label = 'Generic'
SET b:Organisation
SET b.language = b.language[0]
REMOVE b:Page, b.label;

//Remove topic and language
MATCH (b:Page)
REMOVE b.language, b.topic;

//Set book label
MATCH (b:Page)
WHERE b.label = 'Book'
SET b:Book
REMOVE b:Page, b:label, b.publishDate;

//Set youtube label
MATCH (b:Page)
WHERE b.label = 'Youtube'
SET b:Youtube
REMOVE b:Page, b:label, b.linkHistory, b.linkHistoryDate

//Set link label
MATCH (b:Page)
WHERE b.label = 'Link'
SET b:Link
REMOVE b:Page, b:label;

//Add new constraints
CREATE CONSTRAINT ON (b:Answer) ASSERT b.answerId IS UNIQUE;
DROP CONSTRAINT ON (page:Page) ASSERT page.pageId IS UNIQUE;

//Remove all blogs
MATCH (:User)-[written:WRITTEN]->(b:Blog)
OPTIONAL MATCH (b)<-[rel]-(recommendation:Recommendation)<-[rel2:RECOMMENDS]-(:User)
DELETE written, rel, rel2, b, recommendation;

//Set Answer label
MATCH (b:Page)
SET b:Answer
SET b.answerId = b.pageId
REMOVE b.pageId;

//Page with generic label to Organisation
MATCH (b:Page)
WHERE b.label = 'Generic'
SET b:Organisation
SET b.language = b.language[0]
REMOVE b:Page, b.label;

//Remove topic and language
MATCH (b:Page)
REMOVE b.language, b.topic;

//Set book label
MATCH (b:Page)
WHERE b.label = 'Book'
SET b:Book
REMOVE b:Page, b:label, b.publishDate;

//Set youtube label
MATCH (b:Page)
WHERE b.label = 'Youtube'
SET b:Youtube
REMOVE b:Page, b:label, b.linkHistory, b.linkHistoryDate

//Set link label
MATCH (b:Page)
WHERE b.label = 'Link'
SET b:Link
REMOVE b:Page, b:label;

//Set new privacy settings
MATCH (u:User)
SET u.privacyMode = 'public';

MATCH (u:User)-[rel:HAS_PRIVACY|HAS_PRIVACY_NO_CONTACT]->(privacy:Privacy)
DELETE rel, privacy;

//Add new constraints
CREATE CONSTRAINT ON (b:Answer) ASSERT b.answerId IS UNIQUE;
Set new privacy settings and remove old ones.
Set new privacy settings and remove old ones.
