# Canton \`participant.db.migrate\` questions

**URL:** <https://forum.canton.network/t/canton-participant-db-migrate-questions/4571>\
**Category:** App Development\
**Tags:** damlhub, canton\
**Created:** [May 19, 2022, 3:00pm UTC](https://forum.canton.network/t/canton-participant-db-migrate-questions/4571 "2022-05-19T15:00:26Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Porter](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/daniel_porter/32/1171_2.png) [@Daniel\_Porter](https://forum.canton.network/u/Daniel_Porter)\
**Post date:** [May 19, 2022, 3:00pm UTC](https://forum.canton.network/t/canton-participant-db-migrate-questions/4571/1 "2022-05-19T15:00:26Z")

</div>

Just looking for sanity checking from team Canton:

While in the process of getting canton up and running on Daml Hub, we upgraded Canton to 2.2.0, which requires a schema migration. Because we weren’t handling migrations, this broke our existing canton test instances.

To rectify this, my plan is to modify our participant + domain bootstrap scripts to include

```haskell
participant.stop
participant.db.migrate
participant.start

```

so that canton schema changes will be automatically applied to our database.

Are there obvious problems to this approach/a better way? I didn’t see any way to do without having to start the participant, stop the participant, and then start it again.

Later iterations we’d like to implement rolling updates and give users windows on downtime occurs, rather than doing it as part of a startup script, but for now just going for “simplest thing that will reliably work.”

---

<div class="post-metadata">

**Author:** ![soren](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/soren/32/51_2.png) [@soren](https://forum.canton.network/u/soren)\
**Post date:** [May 19, 2022, 3:11pm UTC](https://forum.canton.network/t/canton-participant-db-migrate-questions/4571/2 "2022-05-19T15:11:01Z")

</div>

Hi Daniel,

If there are pending migrations then the start of a participant node would fail. I suggest you start Canton with the cli option `--manual-start`, which prevents the participant nodes from starting automatically. Then in your bootstrap script you run the `participant.db.migrate` and then start the participant (and all the other nodes you may have in the config).

And as you said about maintenance windows, we do recommend to run the DB migrations explicitly and not automatically on each start.

---

<div class="post-metadata">

**Author:** ![Daniel\_Porter](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/daniel_porter/32/1171_2.png) [@Daniel\_Porter](https://forum.canton.network/u/Daniel_Porter)\
**Post date:** [May 19, 2022, 4:34pm UTC](https://forum.canton.network/t/canton-participant-db-migrate-questions/4571/3 "2022-05-19T16:34:23Z")

</div>

For posterity’s sake:

I ended up creating a file called `migrate.scala` that looked like:

```haskell
participant1.db.migrate

```

and then running the command:

```haskell
bin/canton run --config daml-hub-participant.conf --manual-start migrate.scala

```

This needs to be run while the node is not operational.

---

<div class="post-metadata">

**Author:** ![stephenwsun](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stephenwsun/32/4543_2.png) [@stephenwsun](https://forum.canton.network/u/stephenwsun)\
**Post date:** [October 4, 2022, 3:09pm UTC](https://forum.canton.network/t/canton-participant-db-migrate-questions/4571/4 "2022-10-04T15:09:18Z")

</div>

What’s the best way to do this migration when the participant is running in a Kubernetes pod?

---

<div class="post-metadata">

**Author:** ![stephenwsun](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stephenwsun/32/4543_2.png) [@stephenwsun](https://forum.canton.network/u/stephenwsun)\
**Post date:** [October 4, 2022, 4:29pm UTC](https://forum.canton.network/t/canton-participant-db-migrate-questions/4571/5 "2022-10-04T16:29:12Z")

</div>

Running into this error when running manual start

{“timeStamp”:“2022-10-04T16:26:54.896Z”,“message”:“Running CoordinatedShutdown with reason [ActorSystemTerminateReason]”,“logger”:“akka.actor.CoordinatedShutdown”,“thread”:“canton-env-execution-context-17”,“level”:“INFO”}

{“timeStamp”:“2022-10-04T16:27:14.845Z”,“message”:“Starting Canton version 2.3.4”,“logger”:“com.digitalasset.canton.CantonEnterpriseApp$”,“thread”:“main”,“level”:“INFO”}

{“timeStamp”:“2022-10-04T16:27:15.787Z”,“message”:“Can not determine user home directory using the java system property `user.home` \n (is set to /home/app). Please set it \non jvm startup using -Duser.home=…”,“logger”:“com.digitalasset.canton.console.AmmoniteConsoleConfig$”,“thread”:“main”,“level”:“WARN”}

{“timeStamp”:“2022-10-04T16:27:16.410Z”,“message”:“Deriving 2 as number of threads from ‘sys.runtime.availableProcessors()’. Please use ‘-Dscala.concurrent.context.numThreads’ to override.”,“logger”:“com.digitalasset.canton.environment.EnterpriseEnvironment”,“thread”:“main”,“level”:“INFO”}

{“timeStamp”:“2022-10-04T16:27:16.763Z”,“message”:“Slf4jLogger started”,“logger”:“akka.event.slf4j.Slf4jLogger”,“thread”:“canton-env-execution-context-17”,“level”:“INFO”}

{“timeStamp”:“2022-10-04T16:27:18.246Z”,“message”:“Manual start requested.”,“logger”:“com.digitalasset.canton.environment.EnterpriseEnvironment”,“thread”:“main”,“level”:“INFO”}

Compiling (synthetic)/ammonite/predef/ArgsPredef.sc

Compiling /(console)

sh: /dev/tty: No such device or address

Nonzero exit value: 1

---

<div class="post-metadata">

**Author:** ![Daniel\_Porter](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/daniel_porter/32/1171_2.png) [@Daniel\_Porter](https://forum.canton.network/u/Daniel_Porter)\
**Post date:** [October 4, 2022, 4:32pm UTC](https://forum.canton.network/t/canton-participant-db-migrate-questions/4571/6 "2022-10-04T16:32:10Z")

</div>

This is probably best as another question - (un)fortunately, we run ours in kubernetes and I haven’t run into this. It looks like it’s unable to run because it needs `user.home` set - you could try setting that.

---

<div class="post-metadata">

**Author:** ![stephenwsun](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stephenwsun/32/4543_2.png) [@stephenwsun](https://forum.canton.network/u/stephenwsun)\
**Post date:** [October 4, 2022, 4:37pm UTC](https://forum.canton.network/t/canton-participant-db-migrate-questions/4571/7 "2022-10-04T16:37:18Z")

</div>

Thanks Daniel, I created a new ticket here: [Canton Manual Start Failing in Kubernetes Pod](https://discuss.daml.com/t/canton-manual-start-failing-in-kubernetes-pod/5355)

---

<div class="post-metadata">

**Author:** ![stephenwsun](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stephenwsun/32/4543_2.png) [@stephenwsun](https://forum.canton.network/u/stephenwsun)\
**Post date:** [October 4, 2022, 4:54pm UTC](https://forum.canton.network/t/canton-participant-db-migrate-questions/4571/8 "2022-10-04T16:54:59Z")

</div>

When I tested locally without setting user.home, it was still able to run and start up. What’s the best way to set this?

---

<div class="post-metadata">

**Author:** ![Daniel\_Porter](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/daniel_porter/32/1171_2.png) [@Daniel\_Porter](https://forum.canton.network/u/Daniel_Porter)\
**Post date:** [October 4, 2022, 8:47pm UTC](https://forum.canton.network/t/canton-participant-db-migrate-questions/4571/9 "2022-10-04T20:47:12Z")

</div>

(for posterity’s sake again: [Canton Manual Start Failing in Kubernetes Pod - #2 by stephenwsun](https://discuss.daml.com/t/canton-manual-start-failing-in-kubernetes-pod/5355/2) you can set the `--no-tty` argument when running canton to prevent this)
