db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Guy Davis (JIRA)" <j...@apache.org>
Subject [jira] Created: (DDLUTILS-180) DropAllTables command
Date Wed, 18 Jul 2007 15:49:04 GMT
DropAllTables command
---------------------

                 Key: DDLUTILS-180
                 URL: https://issues.apache.org/jira/browse/DDLUTILS-180
             Project: DdlUtils
          Issue Type: New Feature
          Components: Ant Tasks
    Affects Versions: 1.0
         Environment: JDK 1.6.0_02
Win XP
Oracle 10g, SqlServer 2005, Derby
            Reporter: Guy Davis
            Assignee: Thomas Dudziak
             Fix For: 1.0


Adding a command that allows the DDLToDatabase task to drop all the tables in the specified
database by issuing a bunch of drop table commands.  This is very handy for us when we want
to quickly clean out a database without dropping the entire database itself. 

Example usage:

<target name="db.clean" description="Drops all tables and constraints in the target DB.">
    <input addproperty="db.clean.confirm" message="Are you sure you wish to drop all tables
in this DV_MASTER database: ${db.master.url} (${db.master.user}) and in this DV_REFERENCE
database: ${db.reference.url} (${db.reference.user})? " validargs="y,n" />
    <condition property="db.clean.abort">
      <equals arg1="n" arg2="${db.clean.confirm}" />
    </condition>
    <fail if="db.clean.abort">Database clean aborted by user.</fail>
    <db.clean.macro db.user="${db.master.user}" db.password="${db.master.password}" db.type="${db.master.type}"
db.driver="${db.master.driver}" db.url="${db.master.url}" db.schema="${db.master.schema}"
db.catalog="${db.master.catalog}" />
    <db.clean.macro db.user="${db.reference.user}" db.password="${db.reference.password}"
db.type="${db.reference.type}" db.driver="${db.reference.driver}" db.url="${db.reference.url}"
db.schema="${db.reference.schema}" db.catalog="${db.reference.catalog}"/>
  </target>

  <macrodef name="db.clean.macro">
    <attribute name="db.user" description="Database User Name" />
    <attribute name="db.password" description="Database Password" />
    <attribute name="db.type" description="Type of Database" />
    <attribute name="db.driver" description="Classname of JDBC Driver" />
    <attribute name="db.url" description="JDBC connection URL" />
  	<attribute name="db.schema" description="JDBC schema pattern" />
  	<attribute name="db.catalog" description="JDBC catalog pattern" />
    <sequential>
      <taskdef name="ddl_to_db" classpathref="ddlutils.classpath" classname="org.apache.ddlutils.task.DdlToDatabaseTask"
/>
      <ddl_to_db databaseType="@{db.type}" validateXml="false" schemaPattern="@{db.schema}"
catalogPattern="@{db.catalog}">
        <database url="@{db.url}" driverClassName="@{db.driver}" username="@{db.user}"
password="@{db.password}" />
        <dropAllTables />
      </ddl_to_db>
    </sequential>
  </macrodef>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message