mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
完善脚本
This commit is contained in:
@@ -1,9 +1,22 @@
|
|||||||
def execute = """C:\\Program Files\\PostgreSQL\\15\\bin\\pg_dump.exe -d coal_master -h 127.0.0.1 -p 5432 -U postgres -a --inserts -t t_permission -t t_resource -t t_permission_resources --column-inserts """
|
def execute = """D:\\dev\\postgresql-16.1-1\\bin\\pg_dump.exe -d coal_master -h 192.168.59.128 -p 5432 -U postgres -a --inserts -t t_permission -t t_resource -t t_permission_resources --column-inserts """
|
||||||
.execute(["PGPASSWORD=abc@123"], new File("../"))
|
.execute(["PGPASSWORD=abc@123"], new File("../"))
|
||||||
|
|
||||||
|
|
||||||
|
def bs = new ByteArrayOutputStream()
|
||||||
|
execute.consumeProcessErrorStream(bs)
|
||||||
|
|
||||||
def insertSQL = execute.text.split("\n").findAll { it.startsWith("INSERT") }.collect {it.replace("INSERT INTO public.", "INSERT INTO ")}
|
|
||||||
|
def insertSQL = execute.text.split("\n").findAll { it.startsWith("INSERT") }.collect { it.replace("INSERT INTO public.", "INSERT INTO ") }
|
||||||
|
|
||||||
|
if (execute.exitValue() != 0) {
|
||||||
|
|
||||||
|
println(new String(bs.toByteArray(), "GBK"))
|
||||||
|
throw new Exception("execute.exitValue()!=0")}
|
||||||
|
|
||||||
|
|
||||||
|
if (insertSQL.size() < 10) {
|
||||||
|
throw new Exception("insertSQL.size() < 10")
|
||||||
|
}
|
||||||
|
|
||||||
insertSQL.add(0, """
|
insertSQL.add(0, """
|
||||||
truncate table t_permission;
|
truncate table t_permission;
|
||||||
@@ -17,4 +30,4 @@ truncate table t_resource;
|
|||||||
def lastVersion = new File("../src/main/resources/db/migration/").listFiles().findAll { it.name.matches("V\\d+__.+") }.collect { it.name.split("_")[0].substring(1).toInteger() }.sort().last()
|
def lastVersion = new File("../src/main/resources/db/migration/").listFiles().findAll { it.name.matches("V\\d+__.+") }.collect { it.name.split("_")[0].substring(1).toInteger() }.sort().last()
|
||||||
|
|
||||||
|
|
||||||
(new File("../src/main/resources/db/migration/V${lastVersion+1}__resourceAll.sql")).text = insertSQL.join("\n")
|
(new File("../src/main/resources/db/migration/V${lastVersion + 1}__resourceAll.sql")).text = insertSQL.join("\n")
|
||||||
Reference in New Issue
Block a user