dgrigg / Craft-Migration-Manager

Deprecated - Migration Manager for Craft CMS
MIT License
39 stars 15 forks source link

Asset migrations? #61

Closed thomaskonrad closed 5 years ago

thomaskonrad commented 5 years ago

I successfully migrated fields, sections, categories, etc. Thanks for that, it's awesome!

I could however not find any possibility to migrate assets. Is it possible?

ilicmarko commented 5 years ago

First of all I am not sure what you mean. If you mean to migrate physically the assets then, no. If you mean to migrate thing inside assets field then yes.

It is possible, it is a bit hidden in the doc but here it is:

In the case of assets you will need to ensure the matching asset (based on asset source/folder/filename) exists on the destination site.

The actual assets migration isn't present because it is simple enough to migrate on your own. Simple upload the images from your folder to the destination craft again and there you have it.

thomaskonrad commented 5 years ago

I'm not sure if I understand that correctly. When I go to "Create Migration" in the CraftCMS Admin menu, I see "Fields", "Sections", "Categories", "Sites", "Asset Volumes", "Image Transforms". So when I create a migration for Asset Volumes, I suppose the assets themselves won't be migrated, correct?

Further, when I go to my entries, mark them all with the checkbox at the top, and click the little cogwheel, I get the option "Create Migration". But I don't get this option when i go to "Assets" on the left.

I understand that I have to copy the actual files manually from one site to the other. I'm only talking about the metadata.

I migrated all my Entries from one site to another, and all the Asset fields were empty. Are Asset field values supposed to be migrated together with my Entries?

ilicmarko commented 5 years ago

I'm not sure if I understand that correctly. When I go to "Create Migration" in the CraftCMS Admin menu, I see "Fields", "Sections", "Categories", "Sites", "Asset Volumes", "Image Transforms". So when I create a migration for Asset Volumes, I suppose the assets themselves won't be migrated, correct?

Yes, this will only migrate the buckets/volumes.

Further, when I go to my entries, mark them all with the checkbox at the top, and click the little cogwheel, I get the option "Create Migration". But I don't get this option when i go to "Assets" on the left.

Yes, as I said you can't migrate the actual assets. By downloading them (somehow) and then uploading them to the SAME buckets and folders.

I understand that I have to copy the actual files manually from one site to the other. I'm only talking about the metadata.

No, this is probably because the only assets meta data you have available is the Title. I also find this as a bit of a drawback. @dgrigg can probably shed more light on this.

I migrated all my Entries from one site to another, and all the Asset fields were empty. Are Asset field values supposed to be migrated together with my Entries?

This is what I wrote in the first post. You have to upload the assets first. Here is a simple flow:

  1. Export asset buckets
  2. Export content (entries)
  3. Download images
  4. Import asset buckets
  5. Upload images to right buckets and folders
  6. Import content

It has to be this way because the way it exports the assets field, example:

"photo":[
  {
    "elementType":"craft\\\\elements\\\\Asset",
    "filename":"github-image.jpg",
    "folder":"AWS S3",
    "source":"awsS3"
  }
]

As you can see there is no "special" reference here. The way it "connects" images is by matching the filename + folder + source, also it will do a check if this exists. If you haven't uploaded your image it result in an empty field.


Hope I helped

dgrigg commented 5 years ago

@thomaskonrad @ilicmarko currently Migration Manager does not support exporting assets or their related meta data. I don't foresee a version where the actual binary images would be exported since the whole goal of most systems is too keep large BLOBs out of repositories. You raise an interesting point about the meta data though. That's something I will look into.

When creating entry/category/global content migrations that contain asset fields a reference to the file(s) in the asset field is included in the migration. When the migration runs on the destination side it looks for the matching asset (based on asset volume and filename) in the destination server's asset volumes and if it's found creates the reference to the asset. If no match is found the field will be left blank.

thomaskonrad commented 5 years ago

I see, so the whole story in short: Migrate asset volumes, then copy the asset files to the exact same destination folder (e.g., via FTP), and then migrate the entries. If the asset files are there, the entry reference will be kept.

Thanks guys!