Created
July 29, 2021 20:53
-
-
Save igouss/823e5de9592e7cdb568d1acddde2f5bf to your computer and use it in GitHub Desktop.
Gradle execute SQL script in Postgresql database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.sql.Sql | |
task dropDatabase { | |
doLast { | |
Class.forName("org.postgresql.Driver") | |
def sql = groovy.sql.Sql.newInstance( | |
"jdbc:postgresql://localhost:5432/", | |
${DBA_USER}, | |
${DBA_PASSWORD}, | |
"org.postgresql.Driver" | |
); | |
sql.execute( | |
''' | |
DROP DATABASE IF EXISTS auditstore; | |
DROP OWNED BY auditstore; | |
DROP ROLE IF EXISTS auditstore; | |
''' | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment