grails limited table creation

后端 未结 2 1110
别跟我提以往
别跟我提以往 2021-01-06 06:34

I\'d like to use the Grails feature for creating/updating database tables on a limited basis. Specifically, I\'d like Grails to manage some tables, but not all.

Is

2条回答
  •  遥遥无期
    2021-01-06 07:12

    Thanks for the fix Steve. I'm reposting the fix above, but formatted for stackoverflow. When I first tried this I missed the fact that the original if (!command.toLowerCase()...) reversed logic in the fix as if (command.toLowerCase()...), which effectively made it look like dbCreate = "create-drop" in my config/DataSource.groovy was having no effect. I even worked from the HTML source from this page to see intended line breaks of the code, but still missed that vital bit of logic :-( Once I got this entered correctly it worked great.

    private String[] prune(String[] script) {
        List pruned = new ArrayList();
        for (String command : script) {
    
            boolean ignore = false;
    
            for (String ignoreName : IGNORE_NAMES) {
                if (command.toLowerCase().contains(" table " + ignoreName.toLowerCase() + " ")) {
                    ignore = true;
                    break;
                }
            }    
    
            if (!ignore) {
                pruned.add(command);
            }
        }
        return pruned.toArray(new String[pruned.size()]);
    }
    

提交回复
热议问题