Skip to content

Conversation

@Masara
Copy link

@Masara Masara commented Mar 16, 2025

I added field migrations for

  • Image to Asset fields,
  • collectionlinkselect to contentItemLink fields and
  • translation of the old Set fields to the new JSON syntax.

Furthermore I fixed the part of the code which was supposed to set all migrated contents to "published" and I added the options "Migrate" and "Delete v1 files" to the Migration addon UI for Cockpit v2.

@raffaelj
Copy link
Owner

Thanks. I'm glad, that someone uses the tool.

I didn't use cockpit for a while now and I didn't have time to test your changes, yet - just skimmed your code for now.

Image to Asset fields

If I remember correctly, the image field can't be translated directly to asset fields, because it was possible to link images from the file system, that weren't present in the asset list.

collectionlinkselect to contentItemLink fields
translation of the old Set fields to the new JSON syntax

I'm not familiar with v2 anymore, needs manual testing...

Furthermore I fixed the part of the code which was supposed to set all migrated contents to "published"

I set that on purpose to true, because v1 never had a native concept for published/state management. Therefore everything was set to public by default. Because my own concept was to use a boolean field named published, I added a helper method to fix that state:

https://github.com/raffaelj/cockpit-scripts/blob/master/cockpit-cms-Migrate/Helper/TransformFields.php#L218-L230

and I added the options "Migrate" and "Delete v1 files" to the Migration addon UI for Cockpit v2

Thanks.

As I said, it's too long ago, that I looked into this code and I'm not sure, if/when I'll have another look... So no promises, that it gets merged anytime soon. I leave this PR open, so others can see, that changes exist.

@Masara
Copy link
Author

Masara commented Apr 3, 2025

Thanks. I'm glad, that someone uses the tool.

Thank you for providing the tool :)

If I remember correctly, the image field can't be translated directly to asset fields, because it was possible to link images from the file system, that weren't present in the asset list.

That could be, in my use case there where no Images used on the fields, so I guess I was lucky, but maybe future users can't really use it like this. This code part could be either removed or commented out for now, since currently Assets fields are the only possible Image field replacement 🤔

I'm not familiar with v2 anymore, needs manual testing...

Tested it on my side and it worked, but I can't say that I thought of every use case there is...

I set that on purpose to true, because v1 never had a native concept for published/state management. Therefore everything was set to public by default. Because my own concept was to use a boolean field named published, I added a helper method to fix that state

Ah, I guess I misunderstood your code then and thought it was for doing the opposite...

As I said, it's too long ago, that I looked into this code and I'm not sure, if/when I'll have another look... So no promises, that it gets merged anytime soon. I leave this PR open, so others can see, that changes exist.

No worries, I guess that is the best thing to do right now, since probably not many other people will need to use this anymore 👍 Maybe in the future, if other people find their way here, they could also improve and test the changes made here.

@raffaelj
Copy link
Owner

raffaelj commented Apr 3, 2025

I had another look at the image vs asset thingy. If I can trust my own research, the image field wasn't the problem, but the gallery field. See:

So the direct conversion should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants