Foren
Remove old versions for database upgrade
Adam Brown, geändert vor 6 Jahren.
Remove old versions for database upgrade
Junior Member Beiträge: 27 Beitrittsdatum: 17.07.17 Neueste Beiträge
We're moving from Liferay 6.2 to 7 and need to upgrade the database. Using Oracle 12c, if that makes any difference.
We have lots and lots of revisions. An insane amount. The journal.articles.index.all.versions property can remove old versions in the index. However, I want to actually remove those old versions so they aren't updated to the 7.0 version. I would also like to disable saving old versions, if that's possible.
To pull all the old stuff out, I've heard of only one way to do this, but I can't find any examples. The way I heard is to create a new database (still 6.2 compatible), run a migration tool, exclude all but the newest versions, and done. That way, we can upgrade only what we want to 7. Is this a real thing?
Any thoughts?
Thanks!
We have lots and lots of revisions. An insane amount. The journal.articles.index.all.versions property can remove old versions in the index. However, I want to actually remove those old versions so they aren't updated to the 7.0 version. I would also like to disable saving old versions, if that's possible.
To pull all the old stuff out, I've heard of only one way to do this, but I can't find any examples. The way I heard is to create a new database (still 6.2 compatible), run a migration tool, exclude all but the newest versions, and done. That way, we can upgrade only what we want to 7. Is this a real thing?
Any thoughts?
Thanks!
David H Nebinger, geändert vor 6 Jahren.
RE: Remove old versions for database upgrade
Liferay Legend Beiträge: 14914 Beitrittsdatum: 02.09.06 Neueste Beiträge
IIRC there was a marketplace plugin for version cleanups? I could be wrong, though.
Adam Brown, geändert vor 6 Jahren.
RE: Remove old versions for database upgrade
Junior Member Beiträge: 27 Beitrittsdatum: 17.07.17 Neueste Beiträge
All I could find was this: https://web.liferay.com/marketplace/-/mp/application/36783149
Hasn't been updated in quite a while. Not quite the bulk operation either.
This looks promising though: https://web.liferay.com/web/mitesh/blog/-/blogs/how-to-clean-previous-version-of-documents-from-document-and-media
Hasn't been updated in quite a while. Not quite the bulk operation either.
This looks promising though: https://web.liferay.com/web/mitesh/blog/-/blogs/how-to-clean-previous-version-of-documents-from-document-and-media
Olaf Kock, geändert vor 6 Jahren.
RE: Remove old versions for database upgrade
Liferay Legend Beiträge: 6396 Beitrittsdatum: 23.09.08 Neueste Beiträge
In addition to this cleanup, you'll need Antonio's Oracle interface for Liferay 7, already during the upgrade process, and definitely later during operation.
Alberto Chaparro, geändert vor 6 Jahren.
RE: Remove old versions for database upgrade
Liferay Master Beiträge: 549 Beitrittsdatum: 25.04.11 Neueste Beiträge
Hi Adam,
To cleanup articles you can create a groovy script which calls the API to remove intermediate versions before the upgrade.
To cleanup articles you can create a groovy script which calls the API to remove intermediate versions before the upgrade.
Daniel Tyger, geändert vor 6 Jahren.
RE: Remove old versions for database upgrade
Regular Member Beiträge: 105 Beitrittsdatum: 06.02.13 Neueste BeiträgeAlberto Chaparro:
Hi Adam,
To cleanup articles you can create a groovy script which calls the API to remove intermediate versions before the upgrade.
Alberto - can you share such a script / sample?
Alberto Chaparro, geändert vor 6 Jahren.
RE: Remove old versions for database upgrade
Liferay Master Beiträge: 549 Beitrittsdatum: 25.04.11 Neueste Beiträge
Hi Daniel,
You can do something like this:
Get the number of JournalArticleResource:
Run through the JournalArticleResources:
Run through the list of JournalArticleResource to get the related JournalArticle (using a Dynamic query due to the performance):
Run through the list of JournalArticle and remove the articles you consider depending on the version, status, etc.:
(This examples are from 6.0.x but the API are still available, maybe they have a few more parameters)
I hope it helps.
Regards.
You can do something like this:
Get the number of JournalArticleResource:
int articlesResourcesCount =
JournalArticleResourceLocalServiceUtil.
getJournalArticleResourcesCount();
Run through the JournalArticleResources:
List<journalarticleresource> journalArticleResources =
JournalArticleResourceLocalServiceUtil.
getJournalArticleResources(start, end);</journalarticleresource>
Run through the list of JournalArticleResource to get the related JournalArticle (using a Dynamic query due to the performance):
DynamicQuery dq =
DynamicQueryFactoryUtil.forClass(JournalArticle.class)
.setProjection(ProjectionFactoryUtil.projectionList()
.add(ProjectionFactoryUtil.property("id"))
.add(ProjectionFactoryUtil.property("version"))
.add(ProjectionFactoryUtil.property("status")))
.add(PropertyFactoryUtil.forName("groupId")
.eq(journalArticeResource.getGroupId()))
.add(PropertyFactoryUtil.forName("articleId")
.eq(journalArticeResource.getArticleId()))
.addOrder(OrderFactoryUtil.asc("version"));
Run through the list of JournalArticle and remove the articles you consider depending on the version, status, etc.:
JournalArticleLocalServiceUtil.deleteArticle(
groupId, articleId, version, null, null);
(This examples are from 6.0.x but the API are still available, maybe they have a few more parameters)
I hope it helps.
Regards.
Daniel Tyger, geändert vor 6 Jahren.
RE: Remove old versions for database upgrade
Regular Member Beiträge: 105 Beitrittsdatum: 06.02.13 Neueste BeiträgeAlberto Chaparro:
You can do something like this:
...
I hope it helps.
Regards.
Thank you, very kindly Alberto!
Daniel Tyger, geändert vor 5 Jahren.
RE: Remove old versions for database upgrade
Regular Member Beiträge: 105 Beitrittsdatum: 06.02.13 Neueste BeiträgeAlberto Chaparro:
Hi Daniel,
You can do something like this:
(These examples are from 6.0.x but the API are still available, maybe they have a few more parameters)
Regards.
I know it's been a while, but... for anyone else who wants a complete script that accomplishes this in Liferay 6.2:
https://web.liferay.com/web/daniel.tyger/blog/-/blogs/pre-upgrade-scripting-6-2-dxp-pt-3-web-content-version-cleanup
David H Nebinger, geändert vor 5 Jahren.
RE: Remove old versions for database upgrade
Liferay Legend Beiträge: 14914 Beitrittsdatum: 02.09.06 Neueste Beiträge
Nice job, Daniel!
Alberto Chaparro, geändert vor 5 Jahren.
RE: Remove old versions for database upgrade
Liferay Master Beiträge: 549 Beitrittsdatum: 25.04.11 Neueste Beiträge
Never is too late Daniel, this is an amazing job!
Thank you so much for sharing!
Thank you so much for sharing!
Adam Brown, geändert vor 6 Jahren.
RE: Remove old versions for database upgrade
Junior Member Beiträge: 27 Beitrittsdatum: 17.07.17 Neueste BeiträgeOlaf Kock:
In addition to this cleanup, you'll need Antonio's Oracle interface for Liferay 7, already during the upgrade process, and definitely later during operation.
We're using EE, I forgot to mention. So we're covered.
Thanks for pointing out the groovy script!
Also, is there any way to disable versioning in Liferay 6 or 7?
Alberto Chaparro, geändert vor 6 Jahren.
RE: Remove old versions for database upgrade
Liferay Master Beiträge: 549 Beitrittsdatum: 25.04.11 Neueste Beiträge
Hi Adam,
No, there is no way to disable versioning in journal articles yet.
Regards.
No, there is no way to disable versioning in journal articles yet.
Regards.