0

Is something like this possible and if yes, is initSql executed each time a connection is established? For example i want to make sure that on each connection the time zone is set to UTC. Or is there a better way to execute connection-init-sql statements?

flyway:
  datasources:
      default:
          initSql: SET ROLE test_role; SET time zone 'UTC'; <--- is this second statement executed?

Thanks!

1 Answer 1

3

Yes, initsql supports multiple statements. It is run "to initialize a new database connection immediately after opening it," so yes, it's run each time a connection is established.

For example, against a test SQL Server database, I ran:

flyway -initSql="select 1; select 2" info

This output the normal content of flyway info, but also included the following after the usual connection info header:

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! I did solve my issue just like you explained :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.