V1 to V2 Migration and Assets Issues

Hi all, I don’t believe this question has been asked before, apologies if it has.

I am a beginner/intermediate user of GetCockpit and previously had an educational website up and running fine on v1. I am now migrating to v2 due to changes in PHP version of my hosting server.

The cockpit files are hosted on a subdomain: ‘…/cockpit-master/’ previously I used the defines.php file to point links to the correct subdomain, along with a modification to the .HTACCESS file’s rewrite rule (RewriteRule .* /cockpit-master/index.php [L]). With v2 most things seem to be working with just the change in the ReWriteRule as I believe defines.php has been superseded.

The thread ‘Converting from V1 to V2: Collections - Cockpit v2’ (Converting from V1 to V2: Collections) was very helpful for migrating collection data into V2. Thanks to Ronaldaug for his article on modifying sql database entries.

My old website used layouts for variable page layouts, I have found that I am needing to make additional changes to the sql database as the JSON tag ‘component’ that was used to denote a layout block in V1 has now changed to a tag called ‘data’ in V2. However changing the sql seems to allow HTML data to be pulled from the V1 sql database into V2 OK.

I am now looking to migrate a series of images that were previously saved as Assets in V1, does anyone have any experience or advise on this? I was planning on seeing if a similar method to Ronalaug’s would work with assets.

Unfortunately I am falling at the first hurdle and getting a 404 error when trying access ‘Assets’ through the main user landing screen. All other links are working fine (‘Content’, ‘API’, ‘Search’ etc). I have tried to locate where the Assets link should point to to see if its a address error (due to the website being in a subdomain). Does anyone have any thoughts?

Thanks in advance.

Stage 1:

Put the kettle on, make a brew - you may need it!

Background of SQL file function:

My understanding of the sqlite structure for assets for V1 and V2 is below, these files are located at …/storage/data/

V1 sql files

  • Cockpit.sqlite asset_folders
    • Gives folders
    • States whether a folder is a sub folder under the {_p:…} attribute
  • Cockpit.sqlite asset
    • Gives the link/address to each asset within the uploads folder: i.e:
      • /2020/04/07/”image or asset name”.svg
      • Is contained in storage/uploads/2020/04/07/
      • And is file: ”image or asset name”.svg

V2 sql files

  • App.sqlite assets
    • Gives the link/address to each asset within the uploads folder:
  • Assets.sqlite folders
    • Gives folder breakdown
    • States whether a folder is a sub folder under the {_p:…} attribute
    • States the user who created the folder

Copy over raw data:

Copy over whole storage/uploads folder from v1 to v2 install directory. Keeping all filenames and subfolders the same. This ensure the old raw data from v1 is still present in the v2 folder structure.

Create folder structure in Cockpit v2:

In v2 cockpit interface create the same asset folder and subfolders as your v1 interface. You can always look at the data in V1 Cockpit.sqlite if your not sure. It is worth adding in a dummy asset/image into the v2 files as you will need to grab some of it’s JSON attributes for later in the process.

Rename the new v2 folder IDs to match your old v1 folder IDs:

Rename all the folder id’s in Assets.sqlite folders to match the old folder id’s (“3dfe75**********18e”) in Cockpit.sqlite asset_folders. Make sure you rename both the folder name itself (the {id: …} attribute) and the parent folder attribute (the {_p:…} attribute).

Reconfiguring the asset link addresses:

Go into Cockpit.sqlite asset, export the table out of the Cockpit.sqlite asset table and import into App.sqlite database as a new table. Rename the old “assets” table so you still have a copy for reference. Rename the newly imported table as “assets”. Ensure that the new database tables have the same field heading, field heading types and primary keys:

Mending the Assets JSON:

The new assets JSON seems to have some additional information or has renamed some attributes as far as I can tell.

New asset properties that need manually adding:

“_hash”: “c4*******************465d8”, note sure what this attribute does, can anyone advise?

“colors”: null,

“height”: null,

“width”: null

“type”: “image”,

“_cby”: “3d*********18e”, created by username

“_hash”:, “_cby”: and “type” I believe are new attributes. For “_hash” and “_cby” I coped the same value for all the assets to import as the dummy asset I made in the “Create folder structure in Cockpit v2:” stage above. Depending on your asset types you may need to upload a few different dummy files to see how the attribute changes, all my assets to import were images so I was able to use “type”: “image”, throughout.

If any of the variables were already present in the v1 JSON data, the sql editor I was using automatically ignored a “null” assignment when I manually copied in the data above.

Upload updated databases:

Once both the Apps.sqlite and Assets.sqlite databases have been amended upload these back into the …/storage/data/ area. Move, rename or delete the old databases and supersede with your newly edited files. NOTE: it is not possible to overwrite app.sqlite while you are logged into Cockpit on a browser.

Further work:

Its worth noting that the above worked ok for me.

It may be possible to skip some of the steps, I haven’t had a chance to play around to understand what steps definitely are needed and what just worked coincidentally.

I am not 100% what the “_hash” attribute is used for, I am hoping using the same value for all assets doesn’t create problems further down the line. If it does I will try to update.

I hope this helps!

1 Like