# How to set up automated migration

**URL:** <https://discuss.dgraph.io/t/how-to-set-up-automated-migration/10758>\
**Category:** Dgraph\
**Tags:** kind:question\
**Created:** [October 4, 2020, 3:15pm UTC](https://discuss.dgraph.io/t/how-to-set-up-automated-migration/10758 "2020-10-04T15:15:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![whollacsek](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/whollacsek/32/4997_2.png) [@whollacsek](https://discuss.dgraph.io/u/whollacsek)\
**Post date:** [October 4, 2020, 3:15pm UTC](https://discuss.dgraph.io/t/how-to-set-up-automated-migration/10758/1 "2020-10-04T15:15:31Z")

</div>

Dgraph seems to be a very promising database, I’ve read the documentation, however I can’t figure out a viable path to set up schema and data migration. Can a core member shed some light on this topic?

Related question: how are you guys managing deployment on your environments?

---

<div class="post-metadata">

**Author:** ![anand](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/anand/32/5674_2.png) [@anand](https://discuss.dgraph.io/u/anand)\
**Post date:** [October 5, 2020, 2:52am UTC](https://discuss.dgraph.io/t/how-to-set-up-automated-migration/10758/3 "2020-10-05T02:52:01Z")

</div>

Welcome William!

- We usually recommend new users to go through a tour of dgraph [here](https://dgraph.io/tour/). This will help you understand the schema and query aspects.

- For migration:  
You can [export](https://dgraph.io/docs/deploy/dgraph-administration/#exporting-database) database and schema from an existing Dgraph instance.  
You can then either do a [bulk or live load](https://dgraph.io/docs/deploy/fast-data-loading/). Bulk load is used when loading a large amount of data for the first time in a fresh cluster, while live load can be used for loading data into an already running cluster.

- Automation  
[Here](https://github.com/dgraph-io/charts) is a helm chart for kubernetes that might be helpful.

---

<div class="post-metadata">

**Author:** ![whollacsek](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/whollacsek/32/4997_2.png) [@whollacsek](https://discuss.dgraph.io/u/whollacsek)\
**Post date:** [October 5, 2020, 1:01pm UTC](https://discuss.dgraph.io/t/how-to-set-up-automated-migration/10758/5 "2020-10-05T13:01:55Z")

</div>

Thanks for the reply @anand. The use case that I’m looking for is: I would like to have the schema automatically applied during CI and run necessary data migration.

From what I understood, dgraph does not provide a straight forward solution and require the developer to code schema and data migration logic themselves. If this is correct could you give me the explanation on how to proceed?

---

<div class="post-metadata">

**Author:** ![anand](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/anand/32/5674_2.png) [@anand](https://discuss.dgraph.io/u/anand)\
**Post date:** [October 5, 2020, 3:24pm UTC](https://discuss.dgraph.io/t/how-to-set-up-automated-migration/10758/6 "2020-10-05T15:24:18Z")

</div>

Hi @whollacsek,  
We can certainly apply schema dynamically during migration or any other CI activity. In fact, there are Dgraph users who add types and other schema elements _while_ processing their real-time data streams.

- Dgraph clients have an “alter” provision to mutate the schema. Here is the detail [on alter from a Java client](https://github.com/dgraph-io/dgraph4j#altering-the-database).

- In addition to this, you can pass the schema as a part of the [bulk loader](https://dgraph.io/docs/deploy/fast-data-loading/). This can be used for initial data load purposes while moving between environments.

---

<div class="post-metadata">

**Author:** ![whollacsek](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/whollacsek/32/4997_2.png) [@whollacsek](https://discuss.dgraph.io/u/whollacsek)\
**Post date:** [October 5, 2020, 3:37pm UTC](https://discuss.dgraph.io/t/how-to-set-up-automated-migration/10758/7 "2020-10-05T15:37:54Z")

</div>

Thanks for the clarification I’ll take a look at both 🙂
