Phragment provides a way for each individual file to be versioned, and each fragment can be updated on it's own. However, it would be useful to be able to create snapshots of a fragment and all it's child fragments:
- To create a versioned package, I'd update a fragment from ZIP and maybe create a snapshot of that fragment called "myapp-1.0". Even if child fragments are individually changed under the fragment later on, accessing the fragment at "myapp-1.0" will always give me the child fragments at the versions they were when the snapshot was taken.
- To track the latest stable and development versions of a package, I might automatically take snapshots of a fragment after the build has published a fragment, and I might call this snapshot "development". Creating a snapshot of the same name on the same fragment as a previous snapshot moves the snapshot pointer. Occasionally I can snapshot the fragment as "stable", effectively giving my software two update channels.
I would imagine the database structure being something like this:
- PhragmentSnapshot
- phid
- primaryFragmentPHID
- snapshotName
- PhragmentSnapshotChild
- snapshotPHID
- fragmentPHID
- fragmentVersionPHID
After creating a snapshot of a ZIP file with two child fragments inside it, those tables might look like:
PhragmentSnapshot:
id | phid | primaryFragmentPHID | snapshotName |
---|---|---|---|
1 | PHID-PHRS-iqzxpmoafts5xtxqlphc | PHID-PHRF-n36ni7cyrof2ntl7scko | stable |
PhragmentSnapshotChild:
id | snapshotPHID | fragmentPHID | fragmentVersionPHID |
---|---|---|---|
1 | PHID-PHRS-iqzxpmoafts5xtxqlphc | PHID-PHRF-n36ni7cyrof2ntl7scko | PHID-PHRV-ciqbyolvkybarfh2plzx |
2 | PHID-PHRS-iqzxpmoafts5xtxqlphc | PHID-PHRF-7bsdbkhni5r6rpu7gqim | PHID-PHRV-nuaphi4zxbmchsj5gzuq |
3 | PHID-PHRS-iqzxpmoafts5xtxqlphc | PHID-PHRF-tjpttwgdgz7ujl5z2qcn | PHID-PHRV-khmnij52cjohw5u3mlsx |
Here, PHID-PHRF-n36ni7cyrof2ntl7scko is the ZIP file. We record this as primaryFragmentPHID so we know exactly what fragment the snapshot was created against (and thus from here the snapshot can be deleted or w/e).
We obviously record the exact versions of all the child fragments as well. However, because we record the PHIDs we can do things like showing "In Snapshots: stable, development" in the history view and in the browse view (when the latest version is in a snapshot).
This means that Conduit methods will also allow you to provide a snapshot name when asking for a version or the differences between hashes and a version of a fragment.