theseion / Fuel

Fuel, the Smalltalk object serializer
https://theseion.github.io/Fuel
MIT License
26 stars 12 forks source link

Version Migration #289

Closed varvello closed 6 months ago

varvello commented 6 months ago

Hi Guys, How can I migrate from Fuel version 3.x.x to another one? The https://theseion.github.io/Fuel/format-migration/ documentation is obsolete!

I want to migrate from: Fuel on Pharo8, FLSerializer class>>currentVersion returns 300 to: Fuel on Pharo10, FLSerializer class>>currentVersion returns 303

Can you help me please?

TIA Davide

theseion commented 6 months ago

Hi @varvello. That's not a simple question, unfortunately. What you should try first is:

  1. load Fuel 3.0.3 into your Pharo 8 image
  2. serialize from Pharo 8 using version 3.0.3
  3. load the serialized state into Pharo 10

If you don't do crazy things with Fuel, that should hopefully work.

tinchodias commented 6 months ago

Hello, the versions sound so close! I wonder if just removing the FLBadVersion check workaround the problem of @varvello.

That error check was (is?) too strict and restrictive... the rationale was: as Fuel only can guarantee correct materialization if the version of the .fuel file and the FlMaterializer are exactly the same, then let's signal an error if the versions don't match, to prevent wrong materializations.

theseion commented 6 months ago

Or change the version string ;)

varvello commented 6 months ago

Hi Guys, I solved it.

My idea was like @theseion already suggested i.e. materialize objects with the old version of fuel, load Fuel3.0.3 and then serialize all the objects.

As I already mentioned, this code https://theseion.github.io/Fuel/format-migration/ is obsolete but I followed its main idea.

Basically I changed:

 (ConfigurationOfFuel project version: newVersion) load.
 serializerClass := Smalltalk at: #FLSerializer.

with:

Metacello new
    repository: 'github://theseion/Fuel:3.0.3/repository';
    baseline: 'Fuel';
    load.

BUT

So the code became:

Metacello new
    repository: 'github://theseion/Fuel:3.0.3/repository';
    baseline: 'Fuel';
    onConflictUseIncoming;
    load.

Finally I put all my old 3.0.0 serialized objects in a dir and migrate the new 3.0.3 objects in a brand new dir. The code is:

allPreFilenames := (FileLocator imageDirectory resolve / 'fuel300’) fileNames.
 objectsByFileName := Dictionary new.

 allPreFilenames do: [ :fileName | 
    objectsByFileName 
        at: fileName 
        put: (FLMaterializer materializeFromFileNamed: (FileLocator imageDirectory resolve / 'fuel300'/ fileName) pathString) ].

Metacello new
    repository: 'github://theseion/Fuel:3.0.3/repository';
    baseline: 'Fuel';
    onConflictUseIncoming;
    load.

 objectsByFileName keysAndValuesDo: [ :fileName :objects |
    FLSerializer 
        serialize: objects  
        toFileNamed: (FileLocator imageDirectory resolve / 'fuel303’/ fileName) pathString.
     ].

That's it!

@theseion if you can, please change the code https://theseion.github.io/Fuel/format-migration/ with mine

theseion commented 6 months ago

Glad it worked and thanks for the detailed feedback. I will update the documentation.

varvello commented 6 months ago

Glad it worked and thanks for the detailed feedback. I will update the documentation.

Thank you very much @theseion. A couple more thoughts:

1) Do you have any explanation about the LGit_GIT_ENOTFOUND error?

2) I also tried to migrate from fuel 3.0.0 to fuel 5.2.2 in Pharo 8 and consequently from fuel 3.0.3 to fuel 5.2.2 in Pharo 10 and... it worked!!

Of course you have to add onConflictUseIncoming on both the environments when loading the 5.2.2 version of Fuel

Metacello new
    repository: 'github://theseion/Fuel:5.2.2/repository';
    baseline: 'Fuel';
    onConflictUseIncoming;
    load.

So the sequence is: On Pharo8

then On Pharo10

theseion commented 6 months ago

I've updated the documentation on migration and upgrading, thanks @varvello.

Do you have any explanation about the LGit_GIT_ENOTFOUND error?

A lot of work has gone into the FFI, the bindings to LibGit2 and Iceberg since Pharo 8. Back then, that was all still pretty experimental (the FFI, for example, was completely redesigned). So I'm not surprised that you saw some spurious errors.

I also tried to migrate from fuel 3.0.0 to fuel 5.2.2 in Pharo 8 and consequently from fuel 3.0.3 to fuel 5.2.2 in Pharo 10 and... it worked!!

That's awesome! I wouldn't have suspected that to work, honestly. I've mentioned it in the docs.

varvello commented 6 months ago

🙏

p.s. The page https://theseion.github.io/Fuel/format-migration/ is down now

I've updated the documentation on migration and upgrading, thanks @varvello.

Do you have any explanation about the LGit_GIT_ENOTFOUND error?

A lot of work has gone into the FFI, the bindings to LibGit2 and Iceberg since Pharo 8. Back then, that was all still pretty experimental (the FFI, for example, was completely redesigned). So I'm not surprised that you saw some spurious errors.

I also tried to migrate from fuel 3.0.0 to fuel 5.2.2 in Pharo 8 and consequently from fuel 3.0.3 to fuel 5.2.2 in Pharo 10 and... it worked!!

That's awesome! I wouldn't have suspected that to work, honestly. I've mentioned it in the docs.

theseion commented 6 months ago

The page https://theseion.github.io/Fuel/format-migration/ is down now

Yes, I've renamed the page. "Format migration" didn't really fit the content.

varvello commented 6 months ago

and the link at the new page is…

The page https://theseion.github.io/Fuel/format-migration/ is down now

Yes, I've renamed the page. "Format migration" didn't really fit the content.

theseion commented 6 months ago

https://theseion.github.io/Fuel/upgrading/