This commit is contained in:
2023-11-16 22:35:22 +08:00
parent c3866047c0
commit aff150852a
12 changed files with 2394 additions and 26 deletions

20
script/genSQL.groovy Normal file
View File

@@ -0,0 +1,20 @@
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 """
.execute(["PGPASSWORD=abc@123"], new File("../"))
def insertSQL = execute.text.split("\n").findAll { it.startsWith("INSERT") }.collect {it.replace("INSERT INTO public.", "INSERT INTO ")}
insertSQL.add(0, """
truncate table t_permission;
truncate table t_permission_resources;
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()
(new File("../src/main/resources/db/migration/V${lastVersion+1}__resourceAll.sql")).text = insertSQL.join("\n")