Hi Ilia,

This a piece of code I was using to test the create db script for each
build (continuous integfration).
You can add as many executions you need with their own configuration
settings overridden.

    <profiles>
        <profile>
            <id>integration_profile</id>
            <activation>
                <property>
                    <name>env</name>
                    <value>int</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>sql-maven-plugin</artifactId>
                        <version>1.4</version>

                        <dependencies>
                            <!-- specify the dependent jdbc driver here -->
                            <dependency>
                                <groupId>mysql</groupId>

<artifactId>mysql-connector-java</artifactId>
                                <version>5.1.15</version>
                            </dependency>
                        </dependencies>

                        <!-- common configuration shared by all executions
-->
                        <configuration>
                            <driver>com.mysql.jdbc.Driver</driver>
                            <url>jdbc:mysql://integration.server:3306</url>
                            <settingsKey>Integration_Database</settingsKey>
                            <!--all executions are ignored if
-Dmaven.test.skip=true
                            <skip>${maven.test.skip}</skip>-->
                        </configuration>

                        <executions>

                            <execution>
                                <id>drop-db</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>execute</goal>
                                </goals>
                                <configuration>
                                    <autocommit>true</autocommit>
                                    <onError>continue</onError>
                                    <srcFiles>

<srcFile>${project.build.outputDirectory}/sql/init/Drop_database.sql</srcFile>
                                    </srcFiles>
                                </configuration>
                            </execution>

                            <execution>
                                <id>create-db</id>
                                <phase>install</phase>
                                <goals>
                                    <goal>execute</goal>
                                </goals>
                                <configuration>
                                    <autocommit>true</autocommit>
                                    <srcFiles>.
                                        <!-- Re build the database-->

<srcFile>${project.build.outputDirectory}/sql/init/Create_database.sql</srcFile>

<srcFile>${project.build.outputDirectory}/sql/init/Create_tables.sql</srcFile>
                                        <!-- For test -->

<srcFile>${project.build.outputDirectory}/sql/datas.sql</srcFile> -->
                                    </srcFiles>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

Hope it helps.

Sébastien Bordes
--------------------------
www.jrebirth.org

2012/2/6 Ilia Ternovich <[email protected]>

> Hi Dave!
>
> Thank you for rapid answer. I *do* have schemas prepared. I need to deploy
> them using existing sql-maven-plugin but due to the lack of documentation
> want to help someone with my original questions. Anyways thanks!
>
> 2012/2/6 Dave Hicks <[email protected]>
>
>> Check out Liquibase.  (www.liquibase.org).  You'll save yourself a lot
>> of headaches managing schemas for two different database vendors, and there
>> is an excellent Maven plugin for it, as well.
>>
>> Cheers -
>> Dave
>>
>>
>>
>> On 02/06/2012 08:18 AM, Ilia Ternovich wrote:
>>
>>> Hi!
>>>
>>> I need to deploy two different database schemas (DDL as well as some
>>> dictionary data) to multiple databases during my build process (e.g. Oracle
>>> and Derby databases).
>>>
>>> The question is similar to old one: http://www.mail-archive.com/**
>>> [email protected]/**msg02440.html<http://www.mail-archive.com/[email protected]/msg02440.html>but
>>>  it is unanswered and I'm really short in documentation with plugin.
>>>
>>> As far as I understand from documentation: http://mojo.codehaus.org/sql-
>>> **maven-plugin/usage.html<http://mojo.codehaus.org/sql-maven-plugin/usage.html>I
>>>  need several executions, right? What I want is to type mvn
>>> sql:execute_derby (or mvn sql:execute_oracle) and plugin will deploy custom
>>> sql scripts onto the database. How can I achieve this?
>>>
>>> Thanks!
>>>
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe from this list, please visit:
>>
>>   
>> http://xircles.codehaus.org/**manage_email<http://xircles.codehaus.org/manage_email>
>>
>>
>>
>


-- 
-------------------------------------------------------------------------------
[email protected] - http://www.webeo.fr

Reply via email to