This is my PostgreSQL version. It is a little rough at the moment and does
not handle all possible conditions
The schemas must all have the owner that is being used to connect, in this
case "ofbiz"
This script also requires the use of a java.local.properties file located in
the ofbiz root directory or in the user's home directory.

        <target name="clean-postgresql" description="Drop and recreate dbs">
        <property file="java.local.properties"/>
                <property file="${user.home}/java.local.properties"/>
        <property name="db.name" value="ofbiz"/>
        <property name="db.driver" value="${local.db.driver}"/>
        <property name="db.host" value="${local.db.host}"/>
        <property name="db.password" value="${local.db.password}"/>
        <property name="db.user" value="${local.db.user}"/>
        <fail message="No postgresql driver, not cleaning postgresql db">
            <condition>
                <not>
                    <available type="file" file="${local.db.driverjar}"
filepath="framework/entity/lib/jdbc/"/>
                </not>
            </condition>
        </fail>
        <echo message="Resetting ${db.name}, ${db.name}olap and
${db.name}tenant"/>
        <sql driver="${db.driver}"
url="jdbc:postgresql://${db.host}/${db.name}" userid="${db.user}"
password="${db.password}" expandproperties="true">
            <classpath>
                <fileset dir="framework/entity/lib/jdbc" includes="*.jar"/>
            </classpath>
                                DROP SCHEMA public CASCADE;
                                CREATE SCHEMA public AUTHORIZATION ofbiz;
                                GRANT ALL ON SCHEMA public TO ofbiz;
                                GRANT ALL ON SCHEMA public TO public;
        </sql>
                <sql driver="${db.driver}"
url="jdbc:postgresql://${db.host}/${db.name}olap" userid="${db.user}"
password="${db.password}" expandproperties="true">
            <classpath>
                <fileset dir="framework/entity/lib/jdbc" includes="*.jar"/>
            </classpath>
                                DROP SCHEMA public CASCADE;
                                CREATE SCHEMA public AUTHORIZATION ofbiz;
                                GRANT ALL ON SCHEMA public TO ofbiz;
                                GRANT ALL ON SCHEMA public TO public;
        </sql>
        <sql driver="${db.driver}"
url="jdbc:postgresql://${db.host}/${db.name}tenant" userid="${db.user}"
password="${db.password}" expandproperties="true">
            <classpath>
                <fileset dir="framework/entity/lib/jdbc" includes="*.jar"/>
            </classpath>
                                DROP SCHEMA public CASCADE;
                                CREATE SCHEMA public AUTHORIZATION ofbiz;
                                GRANT ALL ON SCHEMA public TO ofbiz;
                                GRANT ALL ON SCHEMA public TO public;
        </sql>
    </target>



--
View this message in context: 
http://ofbiz.135035.n4.nabble.com/help-cleanup-the-ofbiz-database-tp4504823p4638964.html
Sent from the OFBiz - User mailing list archive at Nabble.com.

Reply via email to