Flyway framework supports database migration configuration (based on ruby on rails's db migrate idea)

Source: Internet
Author: User
Tags ruby on rails

Objective: To find a framework (or similar framework) that supports frequent database changes in java web Based on the ruby on rails idea and reference oracle ruby on rails: http://www.oracle.com/technetwork/cn/testcontent/kern-rails-migrations-085789-zhs.html [plain] view plaincopy developers are currently keen on using Ruby on Rails. An important reason for this transfer is that Rails provides a robust framework built on the most flexible language to date. One of the features of Rails is the concept of "porting. Porting well demonstrates why developers want to use this framework: Generally, changes to the database management mode are one of the most annoying tasks of the developer team. Most people rely on the DDL stored in the revision control, always be vigilant, so as to ensure that our database creation scripts are up-to-date and consistent during each operation. This solution is very unsuitable for extreme programming projects. As Rails encourages iterative development, it is easy to think of continuous mode changes as a nightmare. Flyway: flyway is an agile tool for database migration. Developed in Java and supports all databases compatible with JDBC. It is mainly used to upgrade your database structure and data while your application version is constantly upgrading. Official Website: http://flywaydb.org/support two modes of migration: 1, based on SQL file migration 2, based on java file migration can be spring management flyway framework, or combined. Project location: (using an SQL file as an example) in the project source code package, the path is db/migration. [if you do not like it, you can name the Location Based on the configuration.] naming convention: 1. prefix (configurable, default value: V) 2. Version (separated by dots or underscores, you can use many places if you like) 3. delimiter (two underscores) 4. Description (separated by underscores or spaces) 5. suffix (configurable, default: SQL) manage and configure [html] view plaincopy <bean id = "flyway" class = "com. googlecode. flyway. core. flyway "init-method =" migrate "> <property name =" dataSource "ref = "... "/>... </bean> <! -- The rest of the application (incl. Hibernate) --> <! -- Must be run after Flyway to ensure the database is compatible with the code --> <bean id = "sessionFactory" class = "... "depends-on =" flyway ">... </bean> Configure dataSource and sessionFactory to depend on flyway. The init-method in the flyway bean. For the first time, you may need to change the init method to initialize the schema_version table. Then you can change it to migrate. Note: flyway does not support version rollback. (Manual, a little more tragic) in the future, if the data is changed to multiple columns, or the data type, no need to notify the R & D personnel back and forth. You can directly write a version of the SQL file. when the project is started, you can check which one has been executed and which one has not been executed. Flyway will directly migrate to the later version. Flyway source http://grepcode.com/file/repo1.maven.org/maven2/com.googlecode.flyway/flyway-core/0.6/com/google/code/flyway/core/Flyway.java

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.