掲示板

Remove old versions for database upgrade

6年前 に Adam Brown によって更新されました。

Remove old versions for database upgrade

Junior Member 投稿: 27 参加年月日: 17/07/17 最新の投稿
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!
thumbnail
6年前 に David H Nebinger によって更新されました。

RE: Remove old versions for database upgrade

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
IIRC there was a marketplace plugin for version cleanups? I could be wrong, though.
6年前 に Adam Brown によって更新されました。

RE: Remove old versions for database upgrade

Junior Member 投稿: 27 参加年月日: 17/07/17 最新の投稿
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
thumbnail
6年前 に Olaf Kock によって更新されました。

RE: Remove old versions for database upgrade

Liferay Legend 投稿: 6403 参加年月日: 08/09/23 最新の投稿
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.
thumbnail
6年前 に Alberto Chaparro によって更新されました。

RE: Remove old versions for database upgrade

Liferay Master 投稿: 549 参加年月日: 11/04/25 最新の投稿
Hi Adam,

To cleanup articles you can create a groovy script which calls the API to remove intermediate versions before the upgrade.
thumbnail
6年前 に Daniel Tyger によって更新されました。

RE: Remove old versions for database upgrade

Regular Member 投稿: 105 参加年月日: 13/02/06 最新の投稿
Alberto 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?
thumbnail
6年前 に Alberto Chaparro によって更新されました。

RE: Remove old versions for database upgrade

Liferay Master 投稿: 549 参加年月日: 11/04/25 最新の投稿
Hi Daniel,

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.
thumbnail
6年前 に Daniel Tyger によって更新されました。

RE: Remove old versions for database upgrade

Regular Member 投稿: 105 参加年月日: 13/02/06 最新の投稿
Alberto Chaparro:

You can do something like this:
...
I hope it helps.

Regards.


Thank you, very kindly Alberto!
thumbnail
5年前 に Daniel Tyger によって更新されました。

RE: Remove old versions for database upgrade

Regular Member 投稿: 105 参加年月日: 13/02/06 最新の投稿
Alberto 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
thumbnail
5年前 に David H Nebinger によって更新されました。

RE: Remove old versions for database upgrade

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
Nice job, Daniel!
thumbnail
5年前 に Alberto Chaparro によって更新されました。

RE: Remove old versions for database upgrade

Liferay Master 投稿: 549 参加年月日: 11/04/25 最新の投稿
Never is too late Daniel, this is an amazing job!

Thank you so much for sharing!
6年前 に Adam Brown によって更新されました。

RE: Remove old versions for database upgrade

Junior Member 投稿: 27 参加年月日: 17/07/17 最新の投稿
Olaf 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?
thumbnail
6年前 に Alberto Chaparro によって更新されました。

RE: Remove old versions for database upgrade

Liferay Master 投稿: 549 参加年月日: 11/04/25 最新の投稿
Hi Adam,

No, there is no way to disable versioning in journal articles yet.

Regards.