# Generate SQL Script for temporal schemas?

**URL:** <https://community.temporal.io/t/generate-sql-script-for-temporal-schemas/12451>\
**Category:** Community Support\
**Created:** [June 10, 2024, 8:40pm UTC](https://community.temporal.io/t/generate-sql-script-for-temporal-schemas/12451 "2024-06-10T20:40:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bbemis](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@bbemis](https://community.temporal.io/u/bbemis)\
**Post date:** [June 10, 2024, 8:40pm UTC](https://community.temporal.io/t/generate-sql-script-for-temporal-schemas/12451/1 "2024-06-10T20:40:51Z")

</div>

Hi,

I was setting up temporal locally with a Postgres database and creating the Postgres database schema by running the `temporal-sql-tool` from the temporalio admin-tools.

My project typically uses flyway for managing all database migrations so I was wondering if there is a way to generate a SQL script with the temporal-sql-tool or another tool instead of updating the database directly. That way I can continue to use flyway for applying the migrations

Thank you

---

<div class="post-metadata">

**Author:** ![Eugene\_Shvartsman](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/eugene_shvartsman/32/6903_2.png) [@Eugene\_Shvartsman](https://community.temporal.io/u/Eugene_Shvartsman)\
**Post date:** [April 15, 2025, 6:11pm UTC](https://community.temporal.io/t/generate-sql-script-for-temporal-schemas/12451/2 "2025-04-15T18:11:02Z")

</div>

Did you get ever get an answer for this? We are in the same boat as you.

---

<div class="post-metadata">

**Author:** ![bbemis](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@bbemis](https://community.temporal.io/u/bbemis)\
**Post date:** [April 15, 2025, 9:44pm UTC](https://community.temporal.io/t/generate-sql-script-for-temporal-schemas/12451/3 "2025-04-15T21:44:05Z")

</div>

nope, that said. We did do some digging on how temporal’s sql tool works and we ended up putting together our own tooling that extracts the SQL migrations from the admin-tools image and writes them to a SQL migration.

So far that seems to be working for us, I think we have done 3 server upgrades since then with that process. But I don’t think I’m really the right person to recommend if that’s a good process or not.

I think it’s fairly similar though to what I saw in [this repo](https://github.com/wwarfield/temporal-self-hosted/blob/main/tools/migrations/generate_migration.py).

It would be really cool if the sql-tool that temporal provides actually had an option to dump the SQL to stdout instead though. That would probably be a better way to go about this.
