Automatically execute sql script plugins

Note: Simple records to facilitate their access to

Plug-name: db-migrator-maven-plugin

 

the pom.xml (prefix match key and configured in environments of database.properties, will be executed with a)

<plugin>
                <groupId>org.javalite</groupId>
                <artifactId>db-migrator-maven-plugin</artifactId>
                <version>${activejdbc.version}</version>
                <configuration>
                    <configFile>${project.basedir}/src/main/resources/database.properties</configFile>
                    <environments>development.test,development</environments>
                </configuration>
                <executions>
                    <execution>
                        <id>dev_migrations</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>migrate</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <!--<dependency>-->
                        <!--<groupId>mysql</groupId>-->
                        <!--<artifactId>mysql-connector-java</artifactId>-->
                        <!--<version>5.1.34</version>-->
                    <!--</dependency>-->
                    <dependency>
                        <groupId>com.h2database</groupId>
                        <artifactId>h2</artifactId>
                        <version>1.4.198</version>
                        <!--<scope>test</scope>-->
                    </dependency>
                </dependencies>
            </plugin>
database.properties
development.driver=org.h2.Driver
development.username=sa
development.password=
development.url=jdbc:h2:~/test


#development.test.driver=com.mysql.jdbc.Driver
#development.test.username=root
#development.test.password=123456
#development.test.url=jdbc:mysql://localhost:3306/movies_test

mvn command

mvn  db-migrator:help
...
[INFO] db-migrator:drop
[INFO]   drops database configured in pom
[INFO] db-migrator:create
[INFO]   creates database configured in pom
[INFO] db-migrator:new
[INFO]   creates a new migration file
[INFO] db-migrator:check
[INFO]   checks that no pending migrations remain. This can be used in build lifecycle to fail the build if pending migrations are found
[INFO] db-migrator:migrate
[INFO]   migrates all pending migrations
[INFO] db-migrator:validate
[INFO]   validates and prints a report listing pending migrations
[INFO] db-migrator:reset
[INFO]   drops/re-creates the database, and runs all migrations, effectively resetting database to pristine state
[INFO] db-migrator:help
[INFO]   prints this message

 Usually the following two steps:

  mvn db-migrator: create create a database based on the database link
mvn db-migrator: migrate execute sql file

Guess you like

Origin www.cnblogs.com/lngo/p/10993812.html