You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by cb...@apache.org on 2008/08/28 08:40:01 UTC
svn commit: r689730 - in /ibatis/trunk/java/ibatis-3/ibatis-3-core/src:
main/java/org/apache/ibatis/migration/commands/
test/java/org/apache/ibatis/adhoc/ test/java/org/apache/ibatis/migration/
test/java/org/apache/ibatis/migration/example/ test/java/o...
Author: cbegin
Date: Wed Aug 27 23:40:00 2008
New Revision: 689730
URL: http://svn.apache.org/viewvc?rev=689730&view=rev
Log:
Added migrator unit/functional tests.
Added:
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/MigratorTest.java
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/README
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/drivers/
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/environments/
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/environments/development.properties
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200210_create_changelog.sql
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200211_create_author.sql
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200212_create_blog.sql
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200213_create_tags_posts.sql
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200214_create_comments.sql
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200215_create_procs.sql
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/bootstrap.sql
Modified:
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/migration/commands/BaseCommand.java
ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/adhoc/AdHocExecutorTest.java
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/migration/commands/BaseCommand.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/migration/commands/BaseCommand.java?rev=689730&r1=689729&r2=689730&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/migration/commands/BaseCommand.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/main/java/org/apache/ibatis/migration/commands/BaseCommand.java Wed Aug 27 23:40:00 2008
@@ -38,6 +38,7 @@
protected List<Change> getMigrations() {
String[] filenames = scriptPath.list();
+ if (filenames == null) throw new MigrationException(scriptPath + " does not exist.");
Arrays.sort(filenames);
List<Change> migrations = new ArrayList<Change>();
for (String filename : filenames) {
Modified: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/adhoc/AdHocExecutorTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/adhoc/AdHocExecutorTest.java?rev=689730&r1=689729&r2=689730&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/adhoc/AdHocExecutorTest.java (original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/adhoc/AdHocExecutorTest.java Wed Aug 27 23:40:00 2008
@@ -91,7 +91,7 @@
}
@Test
- public void should() throws Exception {
+ public void shouldDemonstrateDDLThroughRunMethod() throws Exception {
SimpleDataSource ds = createSimpleDataSource(JPETSTORE_PROPERTIES);
Connection connection = ds.getConnection();
try {
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/MigratorTest.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/MigratorTest.java?rev=689730&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/MigratorTest.java (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/MigratorTest.java Wed Aug 27 23:40:00 2008
@@ -0,0 +1,145 @@
+package org.apache.ibatis.migration;
+
+import org.apache.ibatis.BaseDataTest;
+import org.apache.ibatis.adhoc.AdHocExecutor;
+import org.apache.ibatis.jdbc.SimpleDataSource;
+import org.apache.ibatis.io.Resources;
+import org.junit.*;
+
+import java.io.*;
+import java.net.URL;
+import java.net.URISyntaxException;
+import java.sql.Connection;
+
+import junit.framework.Assert;
+
+public class MigratorTest extends BaseDataTest {
+
+ private static PrintStream out;
+ private static StringOutputStream buffer;
+
+ @BeforeClass
+ public static void setup() throws Exception {
+ out = System.out;
+ buffer = new StringOutputStream();
+ System.setOut(new PrintStream(buffer));
+
+ SimpleDataSource ds = createSimpleDataSource(BLOG_PROPERTIES);
+ Connection conn = ds.getConnection();
+ AdHocExecutor executor = new AdHocExecutor(conn);
+ safeRun(executor, "DROP TABLE comment");
+ safeRun(executor, "DROP TABLE post_tag");
+ safeRun(executor, "DROP TABLE tag");
+ safeRun(executor, "DROP TABLE post");
+ safeRun(executor, "DROP TABLE blog");
+ safeRun(executor, "DROP TABLE author");
+ safeRun(executor, "DROP PROCEDURE selectTwoSetsOfAuthors");
+ safeRun(executor, "DROP PROCEDURE insertAuthor");
+ safeRun(executor, "DROP PROCEDURE selectAuthorViaOutParams");
+ safeRun(executor, "DROP TABLE changelog");
+ conn.commit();
+ conn.close();
+ }
+
+ @AfterClass
+ public static void teardown() {
+ System.setOut(out);
+ }
+
+ @Test
+ public void shouldRunThroughFullMigrationUseCaseInOneTestToEnsureOrder() throws Exception {
+ File f = getExampleDir();
+
+ Migrator.main(args("--path="+f.getAbsolutePath(),"bootstrap", "--env=development"));
+ Assert.assertTrue(buffer.toString().contains("--// Bootstrap.sql"));
+ buffer.clear();
+
+ Migrator.main(args("--path="+f.getAbsolutePath(),"status"));
+ Assert.assertTrue(buffer.toString().contains("...pending..."));
+ buffer.clear();
+
+ Migrator.main(args("--path="+f.getAbsolutePath(),"up"));
+ buffer.clear();
+
+ Migrator.main(args("--path="+f.getAbsolutePath(),"status"));
+ Assert.assertFalse(buffer.toString().contains("...pending..."));
+ buffer.clear();
+
+ Migrator.main(args("--path="+f.getAbsolutePath(),"down"));
+ buffer.clear();
+
+ Migrator.main(args("--path="+f.getAbsolutePath(),"status"));
+ Assert.assertTrue(buffer.toString().contains("...pending..."));
+ buffer.clear();
+
+ Migrator.main(args("--path="+f.getAbsolutePath(),"version", "20080827200215"));
+ buffer.clear();
+
+ Migrator.main(args("--path="+f.getAbsolutePath(),"status"));
+ Assert.assertFalse(buffer.toString().contains("...pending..."));
+ buffer.clear();
+
+ Migrator.main(args("--path="+f.getAbsolutePath(),"--help"));
+ Assert.assertTrue(buffer.toString().contains("--help"));
+ buffer.clear();
+
+
+ }
+
+
+ @Test
+ public void shouldInitTempDirectory() throws Exception {
+ File basePath = getTempDir();
+ Migrator.main(args("--path="+basePath.getAbsolutePath(),"init"));
+ Assert.assertNotNull(basePath.list());
+ Assert.assertEquals(4,basePath.list().length);
+ File scriptPath = new File(basePath.getCanonicalPath() + File.separator + "scripts");
+ Assert.assertEquals(3,scriptPath.list().length);
+ Migrator.main(args("--path="+basePath.getAbsolutePath(),"new","test new migration"));
+ Assert.assertEquals(4,scriptPath.list().length);
+ }
+
+ private String[] args(String... args) {
+ return args;
+ }
+
+ private File getExampleDir() throws IOException, URISyntaxException {
+ URL resourceURL = Resources.getResourceURL(getClass().getClassLoader(), "org/apache/ibatis/migration/example/");
+ File f = new File(resourceURL.toURI());
+ Assert.assertTrue(f.exists());
+ Assert.assertTrue(f.isDirectory());
+ return f;
+ }
+
+ private File getTempDir() throws IOException {
+ File f = File.createTempFile("migration","test");
+ Assert.assertTrue(f.delete());
+ Assert.assertTrue(f.mkdir());
+ Assert.assertTrue(f.exists());
+ Assert.assertTrue(f.isDirectory());
+ return f;
+ }
+
+ private static class StringOutputStream extends OutputStream {
+ private StringBuilder builder = new StringBuilder();
+ public void write(int b) throws IOException {
+ builder.append((char)b);
+// out.write(b);
+ }
+
+ public String toString() {
+ return builder.toString();
+ }
+ public void clear() {
+ builder.setLength(0);
+ }
+ }
+
+ private static void safeRun(AdHocExecutor executor, String sql) {
+ try {
+ executor.run(sql);
+ } catch (Exception e) {
+ //ignore
+ }
+ }
+}
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/README
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/README?rev=689730&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/README (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/README Wed Aug 27 23:40:00 2008
@@ -0,0 +1,38 @@
+Welcome!
+
+This is an iBATIS Migration repository. You can specify the repository
+directory when running migrations using the --path=<repos-directory>
+option. The default path is the current working directory ("./").
+
+The repository base directory contains three subdirectories as follows:
+
+./drivers
+
+Place your JDBC driver .jar or .zip files in this directory. Upon running a
+migration, the drivers will be dynamically loaded.
+
+./environments
+
+In the environments folder you will find .properties files that represent
+your database instances. By default a development.properties file is
+created for you to configure your development time database properties.
+You can also create test.properties and production.properties files.
+The environment can be specified when running a migration by using
+the --env=<environment> option (without the path or ".properties" part).
+
+The default environment is "development".
+
+./scripts
+
+This directory contains your migration SQL files. These are the files
+that contain your DDL to both upgrade and downgrade your database
+structure. By default, the directory will contain the script to
+create the changelog table, plus one empty "first" migration script.
+To create a new migration script, use the "new" command. To run
+all pending migrations, use the "up" command. To undo the last
+migration applied, use the "down" command etc.
+
+For more information about commands and options, run the ibatis
+migration script with the --help option.
+
+Enjoy.
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/environments/development.properties
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/environments/development.properties?rev=689730&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/environments/development.properties (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/environments/development.properties Wed Aug 27 23:40:00 2008
@@ -0,0 +1,8 @@
+## JDBC connection properties.
+driver=org.apache.derby.jdbc.EmbeddedDriver
+url=jdbc:derby:ibderby;create=true
+username=
+password=
+
+# Name of the table that tracks changes to the database
+changelog=CHANGELOG
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200210_create_changelog.sql
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200210_create_changelog.sql?rev=689730&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200210_create_changelog.sql (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200210_create_changelog.sql Wed Aug 27 23:40:00 2008
@@ -0,0 +1,24 @@
+--// Create Changelog
+
+-- Default DDL for changelog table that will keep
+-- a record of the migrations that have been run.
+
+-- You can modify this to suit your database before
+-- running your first migration.
+
+-- Be sure that ID and DESCRIPTION fields exist in
+-- BigInteger and String compatible fields respectively.
+
+CREATE TABLE ${changelog} (
+ ID NUMERIC(20,0) NOT NULL,
+ APPLIED_AT VARCHAR(25) NOT NULL,
+ DESCRIPTION VARCHAR(255) NOT NULL
+);
+
+ALTER TABLE ${changelog}
+ ADD CONSTRAINT PK_${changelog}
+ PRIMARY KEY (id);
+
+--//@UNDO
+
+DROP TABLE ${changelog};
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200211_create_author.sql
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200211_create_author.sql?rev=689730&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200211_create_author.sql (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200211_create_author.sql Wed Aug 27 23:40:00 2008
@@ -0,0 +1,82 @@
+--// First migration.
+-- Migration SQL that makes the change goes here.
+
+CREATE TABLE author (
+ id INT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 10000),
+ username VARCHAR(255) NOT NULL,
+ password VARCHAR(255) NOT NULL,
+ email VARCHAR(255) NOT NULL,
+ bio LONG VARCHAR,
+ favourite_section VARCHAR(25),
+ PRIMARY KEY (id)
+);
+
+--//@UNDO
+-- SQL to undo the change goes here.
+
+DROP TABLE author;
+
+DROP TABLE comment;
+DROP TABLE post_tag;
+DROP TABLE tag;
+DROP TABLE post;
+DROP TABLE blog;
+DROP PROCEDURE selectTwoSetsOfAuthors;
+DROP PROCEDURE insertAuthor;
+DROP PROCEDURE selectAuthorViaOutParams;
+
+CREATE TABLE blog (
+ id INT NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ author_id INT NOT NULL,
+ title VARCHAR(255),
+ PRIMARY KEY (id)
+);
+
+CREATE TABLE post (
+ id INT NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ blog_id INT,
+ author_id INT NOT NULL,
+ created_on TIMESTAMP NOT NULL,
+ section VARCHAR(25) NOT NULL,
+ subject VARCHAR(255) NOT NULL,
+ body CLOB NOT NULL,
+ PRIMARY KEY (id),
+ FOREIGN KEY (blog_id) REFERENCES blog(id)
+);
+
+CREATE TABLE tag (
+ id INT NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ name VARCHAR(255) NOT NULL,
+ PRIMARY KEY (id)
+);
+
+CREATE TABLE post_tag (
+ post_id INT NOT NULL,
+ tag_id INT NOT NULL,
+ PRIMARY KEY (post_id, tag_id)
+);
+
+CREATE TABLE comment (
+ id INT NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ post_id INT NOT NULL,
+ name LONG VARCHAR NOT NULL,
+ comment LONG VARCHAR NOT NULL,
+ PRIMARY KEY (id)
+);
+
+CREATE PROCEDURE selectTwoSetsOfAuthors(DP1 INTEGER, DP2 INTEGER)
+PARAMETER STYLE JAVA
+LANGUAGE JAVA
+READS SQL DATA
+DYNAMIC RESULT SETS 2
+EXTERNAL NAME 'databases.blog.StoredProcedures.selectTwoSetsOfTwoAuthors';
+
+CREATE PROCEDURE insertAuthor(DP1 INTEGER, DP2 VARCHAR(255), DP3 VARCHAR(255), DP4 VARCHAR(255))
+PARAMETER STYLE JAVA
+LANGUAGE JAVA
+EXTERNAL NAME 'databases.blog.StoredProcedures.insertAuthor';
+
+CREATE PROCEDURE selectAuthorViaOutParams(ID INTEGER, OUT USERNAME VARCHAR(255), OUT PASSWORD VARCHAR(255), OUT EMAIL VARCHAR(255), OUT BIO VARCHAR(255))
+PARAMETER STYLE JAVA
+LANGUAGE JAVA
+EXTERNAL NAME 'databases.blog.StoredProcedures.selectAuthorViaOutParams';
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200212_create_blog.sql
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200212_create_blog.sql?rev=689730&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200212_create_blog.sql (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200212_create_blog.sql Wed Aug 27 23:40:00 2008
@@ -0,0 +1,15 @@
+--// First migration.
+-- Migration SQL that makes the change goes here.
+
+CREATE TABLE blog (
+ id INT NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ author_id INT NOT NULL,
+ title VARCHAR(255),
+ PRIMARY KEY (id)
+);
+
+--//@UNDO
+-- SQL to undo the change goes here.
+
+DROP TABLE blog;
+
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200213_create_tags_posts.sql
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200213_create_tags_posts.sql?rev=689730&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200213_create_tags_posts.sql (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200213_create_tags_posts.sql Wed Aug 27 23:40:00 2008
@@ -0,0 +1,35 @@
+--// First migration.
+-- Migration SQL that makes the change goes here.
+
+CREATE TABLE post (
+ id INT NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ blog_id INT,
+ author_id INT NOT NULL,
+ created_on TIMESTAMP NOT NULL,
+ section VARCHAR(25) NOT NULL,
+ subject VARCHAR(255) NOT NULL,
+ body CLOB NOT NULL,
+ PRIMARY KEY (id),
+ FOREIGN KEY (blog_id) REFERENCES blog(id)
+);
+
+CREATE TABLE tag (
+ id INT NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ name VARCHAR(255) NOT NULL,
+ PRIMARY KEY (id)
+);
+
+CREATE TABLE post_tag (
+ post_id INT NOT NULL,
+ tag_id INT NOT NULL,
+ PRIMARY KEY (post_id, tag_id)
+);
+
+--//@UNDO
+-- SQL to undo the change goes here.
+
+DROP TABLE post_tag;
+DROP TABLE tag;
+DROP TABLE post;
+
+
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200214_create_comments.sql
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200214_create_comments.sql?rev=689730&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200214_create_comments.sql (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200214_create_comments.sql Wed Aug 27 23:40:00 2008
@@ -0,0 +1,15 @@
+--// First migration.
+-- Migration SQL that makes the change goes here.
+
+CREATE TABLE comment (
+ id INT NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ post_id INT NOT NULL,
+ name LONG VARCHAR NOT NULL,
+ comment LONG VARCHAR NOT NULL,
+ PRIMARY KEY (id)
+);
+
+--//@UNDO
+-- SQL to undo the change goes here.
+
+DROP TABLE comment;
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200215_create_procs.sql
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200215_create_procs.sql?rev=689730&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200215_create_procs.sql (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/20080827200215_create_procs.sql Wed Aug 27 23:40:00 2008
@@ -0,0 +1,27 @@
+--// First migration.
+-- Migration SQL that makes the change goes here.
+
+CREATE PROCEDURE selectTwoSetsOfAuthors(DP1 INTEGER, DP2 INTEGER)
+PARAMETER STYLE JAVA
+LANGUAGE JAVA
+READS SQL DATA
+DYNAMIC RESULT SETS 2
+EXTERNAL NAME 'databases.blog.StoredProcedures.selectTwoSetsOfTwoAuthors';
+
+CREATE PROCEDURE insertAuthor(DP1 INTEGER, DP2 VARCHAR(255), DP3 VARCHAR(255), DP4 VARCHAR(255))
+PARAMETER STYLE JAVA
+LANGUAGE JAVA
+EXTERNAL NAME 'databases.blog.StoredProcedures.insertAuthor';
+
+CREATE PROCEDURE selectAuthorViaOutParams(ID INTEGER, OUT USERNAME VARCHAR(255), OUT PASSWORD VARCHAR(255), OUT EMAIL VARCHAR(255), OUT BIO VARCHAR(255))
+PARAMETER STYLE JAVA
+LANGUAGE JAVA
+EXTERNAL NAME 'databases.blog.StoredProcedures.selectAuthorViaOutParams';
+
+--//@UNDO
+-- SQL to undo the change goes here.
+
+DROP PROCEDURE selectTwoSetsOfAuthors;
+DROP PROCEDURE insertAuthor;
+DROP PROCEDURE selectAuthorViaOutParams;
+
Added: ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/bootstrap.sql
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/bootstrap.sql?rev=689730&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/bootstrap.sql (added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-core/src/test/java/org/apache/ibatis/migration/example/scripts/bootstrap.sql Wed Aug 27 23:40:00 2008
@@ -0,0 +1,40 @@
+--// Bootstrap.sql
+
+-- This is the only SQL script file that is NOT
+-- a valid migration and will not be run or tracked
+-- in the changelog. There is no @UNDO section.
+
+--// Do I need this file?
+
+-- New projects likely won't need this file.
+-- Existing projects will likely need this file.
+-- It's unlikely that this bootstrap should be run
+-- in the production environment.
+
+--// Purpose
+
+-- The purpose of this file is to provide a facility
+-- to initialize the database to a state before iBATIS
+-- SQL migrations were applied. If you already have
+-- a database in production, then you probably have
+-- a script that you run on your developer machine
+-- to initialize the database. That script can now
+-- be put in this bootstrap file (but does not have
+-- to be if you are comfortable with your current process.
+
+--// Running
+
+-- The bootstrap SQL is run with the "migrate bootstrap"
+-- command. It must be run manually, it's never run as
+-- part of the regular migration process and will never
+-- be undone. Variables (e.g. ${variable}) are still
+-- parsed in the bootstrap SQL.
+
+-- After the boostrap SQL has been run, you can then
+-- use the migrations and the changelog for all future
+-- database change management.
+
+create table BOOTSTRAP (
+ ID NUMERIC(8,0),
+ PRIMARY KEY(ID)
+)
\ No newline at end of file