# Getting multiple migration statements working in a migration file with migratus

**URL:** https://clojureverse.org/t/getting-multiple-migration-statements-working-in-a-migration-file-with-migratus/5261
**Category:** Troubleshooting
**Created:** [December 23, 2019, 4:12am UTC](https://clojureverse.org/t/getting-multiple-migration-statements-working-in-a-migration-file-with-migratus/5261 "2019-12-23T04:12:22Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![ashwinbhaskar](https://clojureverse.org/user_avatar/clojureverse.org/ashwinbhaskar/32/2045_2.png) [@ashwinbhaskar](https://clojureverse.org/u/ashwinbhaskar)
#### Post date: [December 23, 2019, 4:12am UTC](https://clojureverse.org/t/getting-multiple-migration-statements-working-in-a-migration-file-with-migratus/5261/1 "2019-12-23T04:12:22Z")

</div>

I am using `migratus` for managing migrations. [This](https://github.com/yogthos/migratus#multiple-statements) line talks about handling multiple migration statements in a single file. I tried using `--;;` between each statement like it’s given in the link. But I still end up getting

```auto
Execution error (PSQLException) at org.postgresql.jdbc.BatchResultHandler/handleCommandStatus (BatchResultHandler.java:92).
Too many update results were returned.

```

My migration file

```auto
CREATE INDEX foo ON baz USING GIN(col1); -- GIN Index (array)
--;;
CREATE INDEX foo1 ON baz USING GIN(col2); -- GIN Index (array)
--;;
CREATE INDEX foo2 ON baz USING GIN(col3); -- GIN Index (array)
--;;

```

Am I doing something wrong?

---

<div class="post-metadata">

### Author: ![teodorlu](https://clojureverse.org/user_avatar/clojureverse.org/teodorlu/32/2896_2.png) [@teodorlu](https://clojureverse.org/u/teodorlu)
#### Post date: [December 23, 2019, 8:51am UTC](https://clojureverse.org/t/getting-multiple-migration-statements-working-in-a-migration-file-with-migratus/5261/2 "2019-12-23T08:51:51Z")

</div>

Perhaps try wrapping the statements in a transaction?

---

<div class="post-metadata">

### Author: ![ashwinbhaskar](https://clojureverse.org/user_avatar/clojureverse.org/ashwinbhaskar/32/2045_2.png) [@ashwinbhaskar](https://clojureverse.org/u/ashwinbhaskar)
#### Post date: [December 23, 2019, 12:02pm UTC](https://clojureverse.org/t/getting-multiple-migration-statements-working-in-a-migration-file-with-migratus/5261/3 "2019-12-23T12:02:00Z")

</div>

tried, I get the same error.

---

<div class="post-metadata">

### Author: ![ashwinbhaskar](https://clojureverse.org/user_avatar/clojureverse.org/ashwinbhaskar/32/2045_2.png) [@ashwinbhaskar](https://clojureverse.org/u/ashwinbhaskar)
#### Post date: [January 15, 2020, 3:56am UTC](https://clojureverse.org/t/getting-multiple-migration-statements-working-in-a-migration-file-with-migratus/5261/4 "2020-01-15T03:56:47Z")

</div>

The issue is apparently with a single `CREATE INDEX` with `GIN` statement returning multiple rows. The solution suggested (and works) is to wrap each statement in a `DO` block this way

```auto
DO
$$
    BEGIN
    [... your statement here ...]
    END
$$;

```

---

<div class="post-metadata">

### Author: ![teodorlu](https://clojureverse.org/user_avatar/clojureverse.org/teodorlu/32/2896_2.png) [@teodorlu](https://clojureverse.org/u/teodorlu)
#### Post date: [January 15, 2020, 7:51pm UTC](https://clojureverse.org/t/getting-multiple-migration-statements-working-in-a-migration-file-with-migratus/5261/5 "2020-01-15T19:51:53Z")

</div>

Glad you found a solution! Sorry there wasn’t much help to get here 🙂

---

<div class="post-metadata">

### Author: ![system](https://clojureverse.org/uploads/default/original/2X/5/51079bf9e4b7d9466242c06cf1e43b9f8bd6da14.png) [@system](https://clojureverse.org/u/system)
#### Post date: [July 16, 2020, 7:51am UTC](https://clojureverse.org/t/getting-multiple-migration-statements-working-in-a-migration-file-with-migratus/5261/6 "2020-07-16T07:51:56Z")

</div>

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
