Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Download DDL Utils and unzip the file
  • Download the JDBC drivers used to connect to your database and copy the libraries to the lib folder of DDLUitls
  • Create a build.xml file with the code below (change as rquired the data on the database)
    Code Block
    <project name="DDL" default="database-dump" basedir=".">
    
    <path id="runtime-classpath">
      <fileset dir="lib">
        <include name="**/*.jar"/>
        <include name="**/*.zip"/>
      </fileset>
    </path>
    
    <target name="database-dump" description="Dumps the database structure">
      <taskdef name="databaseToDdl"
               classname="org.apache.ddlutils.task.DatabaseToDdlTask">
        <classpath refid="runtime-classpath"/>
      </taskdef>
      <databaseToDdl modelName="DSpace" schemapattern="%" databasetype="postgresql">
        <database url="jdbc:postgresql://localhost:5432/dspace"
                  driverClassName="org.postgresql.Driver"
                  username="dspace"
                  password="dspace"/>
    
        <writeSchemaToFile outputFile="db-schema.xml"/>
        <writeDataToFile outputFile="data.xml" determineschema="true"/>
      </databaseToDdl>
    
    </target>
    </project>
    
    * Run
  •  Run the main task with the command:
    Code Block
    > ant
    
    This will genetare two files, db-schema.xml which contains the structure and data.xml which contains the data of the tables. We will use these files to replicate the database in the in-memory database.

NOTE: HSQLDB doesn't accept columsn with autoincrement which are not PK. The DDL has been modified so all columns with autoincrement are PK

NOTE: in table community_item_count field count renamed to comm_count due to HSQL compatibility issues with the name of the column. Be aware when creating tests for the item counter script

NOTE: in table collection_item_count field count renamed to coll_count due to HSQL compatibility issues with the name of the column. Be aware when creating tests for the item counter script

In-Memory Database

DDL Utils has some limitations on the databases it can connect to. As a result, the choices of in-memory databases are a bit limited. We have decided to use HSQLDB, an open-source and very tested database that recently has released version 2. The database we will use is an in-memory instance, which has no persistence beyond the JVM process that manages it. Once shutdown, all the information will be erased, which makes it a perfect choice for unit testing.

...