Skip to content

Commit

Permalink
language: docu: documentation for the migrate command of damlc (digit…
Browse files Browse the repository at this point in the history
…al-asset#2579)

* language: docu: documentation for the migrate command of damlc

This adds a section on how to migrate between two different versions of
two packages.

* addressing martin's comments

* addressing bernhard's comments
  • Loading branch information
Robin Krom authored Aug 19, 2019
1 parent daf10bf commit 47238a5
Show file tree
Hide file tree
Showing 18 changed files with 406 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ DAML SDK documentation

experimental/warning
daml-integration-kit/index
migrate/index

.. toctree::
:titlesonly:
Expand Down
12 changes: 12 additions & 0 deletions docs/source/migrate/foo-1.0.0/daml.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
sdk-version: 0.0.0
name: foo
source: daml/Foo.daml
parties:
- Alice
- Bob
version: 1.0.0
exposed-modules:
- Foo
dependencies:
- daml-prim
- daml-stdlib
14 changes: 14 additions & 0 deletions docs/source/migrate/foo-1.0.0/daml/Foo.daml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- Copyright (c) 2019 The DAML Authors. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0

--------------------------------------------------------------------------------

daml 1.2
module Foo where

template Foo
with
a : Int
p : Party
where
signatory p
5 changes: 5 additions & 0 deletions docs/source/migrate/foo-1.0.0/ui-backend.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
users
{
Alice { party = "Alice" },
Bob { party = "Bob" }
}
12 changes: 12 additions & 0 deletions docs/source/migrate/foo-2.0.0/daml.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
sdk-version: 0.0.0
name: foo
source: daml/Foo.daml
parties:
- Alice
- Bob
version: 2.0.0
exposed-modules:
- Foo
dependencies:
- daml-prim
- daml-stdlib
21 changes: 21 additions & 0 deletions docs/source/migrate/foo-2.0.0/daml/Foo.daml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- Copyright (c) 2019 The DAML Authors. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0

--------------------------------------------------------------------------------

daml 1.2
module Foo where

template Foo
with
a : Int
p : Party
where
signatory p

template Bar
with
t : Text
p : Party
where
signatory p
16 changes: 16 additions & 0 deletions docs/source/migrate/foo-2.0.0/daml/FooEmbedding.daml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- Copyright (c) 2019 The DAML Authors. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0

--------------------------------------------------------------------------------

daml 1.2
module Foo where

template Foo
with
a : Int
b : Text
p : Party
where
signatory p

5 changes: 5 additions & 0 deletions docs/source/migrate/foo-2.0.0/ui-backend.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
users
{
Alice { party = "Alice" },
Bob { party = "Bob" }
}
1 change: 1 addition & 0 deletions docs/source/migrate/foo-upgrade-2.0.0/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.daml
4 changes: 4 additions & 0 deletions docs/source/migrate/foo-upgrade-2.0.0/build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
:: Copyright (c) 2019 The DAML Authors. All rights reserved.
:: SPDX-License-Identifier: Apache-2.0

daml build --init-package-db=no --package @("foo-1.0.0",[("Foo","FooA")])@ --package @("foo-2.0.0",[("Foo","FooB")])@
5 changes: 5 additions & 0 deletions docs/source/migrate/foo-upgrade-2.0.0/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
# Copyright (c) 2019 The DAML Authors. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

daml build --init-package-db=no --package '("foo-1.0.0",[("Foo","FooA")])' --package '("foo-2.0.0",[("Foo","FooB")])'
13 changes: 13 additions & 0 deletions docs/source/migrate/foo-upgrade-2.0.0/daml.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
sdk-version: 0.0.0
name: foo-upgrade-2.0.0
source: daml/Foo.daml
parties:
- Alice
- Bob
version: 0.0.1
dependencies:
- daml-prim
- daml-stdlib
- /home/drsk/daml/docs/source/migrate/foo-1.0.0/.daml/dist/foo-1.0.0.dar
- /home/drsk/daml/docs/source/migrate/foo-2.0.0/.daml/dist/foo-2.0.0.dar

40 changes: 40 additions & 0 deletions docs/source/migrate/foo-upgrade-2.0.0/daml/Foo.daml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
-- Copyright (c) 2019 The DAML Authors. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0

daml 1.2
module Foo where
import FooA qualified as A
import FooB qualified as B
import FooAInstances()
import FooBInstances()
import DA.Next.Set
import DA.Upgrade
template FooUpgrade
with
op : Party
where
signatory op
nonconsuming choice Upgrade: ContractId B.Foo
with
inC : ContractId A.Foo
sigs : [Party]
controller sigs
do
d <- fetch inC
assert $ fromList sigs == fromList (signatory d)
create $ conv d
template FooRollback
with
op : Party
where
signatory op
nonconsuming choice Rollback: ContractId A.Foo
with
inC : ContractId B.Foo
sigs : [Party]
controller sigs
do
d <- fetch inC
assert $ fromList sigs == fromList (signatory d)
create $ conv d

14 changes: 14 additions & 0 deletions docs/source/migrate/foo-upgrade-2.0.0/daml/FooAInstances.daml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- Copyright (c) 2019 The DAML Authors. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0

{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE NoDamlSyntax #-}
module FooAInstances where
import FooA
import DA.Generics
instance {-# NO_OVERLAP #-} Generic Foo (DA.Generics.D1 ('DA.Generics.MetaData ('DA.Generics.MetaData0 "Foo" "Foo" "foo-1.0.0" 'Prelude.False)) (DA.Generics.C1 ('DA.Generics.MetaCons ('DA.Generics.MetaCons0 "Foo" 'DA.Generics.PrefixI 'Prelude.True)) ((DA.Generics.:*:) (DA.Generics.S1 ('DA.Generics.MetaSel ('DA.Generics.MetaSel0 ('Prelude.Some "a") 'DA.Generics.NoSourceUnpackedness 'DA.Generics.NoSourceStrictness)) (DA.Generics.Rec0 Int)) (DA.Generics.S1 ('DA.Generics.MetaSel ('DA.Generics.MetaSel0 ('Prelude.Some "p") 'DA.Generics.NoSourceUnpackedness 'DA.Generics.NoSourceStrictness)) (DA.Generics.Rec0 Party))))) where
from x
= M1 (case x of { Foo g1 g2 -> M1 (P1 (M1 (K1 g1)) (M1 (K1 g2))) })
to (M1 x)
= case x of { (M1 (P1 (M1 (K1 g1)) (M1 (K1 g2)))) -> Foo g1 g2 }

19 changes: 19 additions & 0 deletions docs/source/migrate/foo-upgrade-2.0.0/daml/FooBInstances.daml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-- Copyright (c) 2019 The DAML Authors. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0

{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE NoDamlSyntax #-}
module FooBInstances where
import FooB
import DA.Generics
instance {-# NO_OVERLAP #-} Generic Bar (DA.Generics.D1 ('DA.Generics.MetaData ('DA.Generics.MetaData0 "Bar" "Foo" "foo-2.0.0" 'Prelude.False)) (DA.Generics.C1 ('DA.Generics.MetaCons ('DA.Generics.MetaCons0 "Bar" 'DA.Generics.PrefixI 'Prelude.True)) ((DA.Generics.:*:) (DA.Generics.S1 ('DA.Generics.MetaSel ('DA.Generics.MetaSel0 ('Prelude.Some "t") 'DA.Generics.NoSourceUnpackedness 'DA.Generics.NoSourceStrictness)) (DA.Generics.Rec0 Text)) (DA.Generics.S1 ('DA.Generics.MetaSel ('DA.Generics.MetaSel0 ('Prelude.Some "p") 'DA.Generics.NoSourceUnpackedness 'DA.Generics.NoSourceStrictness)) (DA.Generics.Rec0 Party))))) where
from x
= M1 (case x of { Bar g1 g2 -> M1 (P1 (M1 (K1 g1)) (M1 (K1 g2))) })
to (M1 x)
= case x of { (M1 (P1 (M1 (K1 g1)) (M1 (K1 g2)))) -> Bar g1 g2 }
instance {-# NO_OVERLAP #-} Generic Foo (DA.Generics.D1 ('DA.Generics.MetaData ('DA.Generics.MetaData0 "Foo" "Foo" "foo-2.0.0" 'Prelude.False)) (DA.Generics.C1 ('DA.Generics.MetaCons ('DA.Generics.MetaCons0 "Foo" 'DA.Generics.PrefixI 'Prelude.True)) ((DA.Generics.:*:) (DA.Generics.S1 ('DA.Generics.MetaSel ('DA.Generics.MetaSel0 ('Prelude.Some "a") 'DA.Generics.NoSourceUnpackedness 'DA.Generics.NoSourceStrictness)) (DA.Generics.Rec0 Int)) (DA.Generics.S1 ('DA.Generics.MetaSel ('DA.Generics.MetaSel0 ('Prelude.Some "p") 'DA.Generics.NoSourceUnpackedness 'DA.Generics.NoSourceStrictness)) (DA.Generics.Rec0 Party))))) where
from x
= M1 (case x of { Foo g1 g2 -> M1 (P1 (M1 (K1 g1)) (M1 (K1 g2))) })
to (M1 x)
= case x of { (M1 (P1 (M1 (K1 g1)) (M1 (K1 g2)))) -> Foo g1 g2 }

40 changes: 40 additions & 0 deletions docs/source/migrate/foo-upgrade-2.0.0/daml/FooManual.daml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
-- Copyright (c) 2019 The DAML Authors. All rights reserved.
-- SPDX-License-Identifier: Apache-2.0

daml 1.2
module Foo where
import FooA qualified as A
import FooB qualified as B
import FooAInstances()
import FooBInstances()
import DA.Next.Set
import DA.Upgrade
template FooUpgrade
with
op : Party
where
signatory op
nonconsuming choice Upgrade: ContractId B.Foo
with
inC : ContractId A.Foo
sigs : [Party]
controller sigs
do
d <- fetch inC
assert $ fromList sigs == fromList (signatory d)
create $ Foo with a = d.a; b = "updated"; p = d.p
template FooRollback
with
op : Party
where
signatory op
nonconsuming choice Rollback: ContractId A.Foo
with
inC : ContractId B.Foo
sigs : [Party]
controller sigs
do
d <- fetch inC
assert $ fromList sigs == fromList (signatory d)
create $ Foo with a = d.a; p = d.p

5 changes: 5 additions & 0 deletions docs/source/migrate/foo-upgrade-2.0.0/ui-backend.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
users
{
Alice { party = "Alice" },
Bob { party = "Bob" }
}
Loading

0 comments on commit 47238a5

Please sign in to comment.