background preloader

Liquibase > DB Refactoring

Liquibase > DB Refactoring

HSQLDB Database Refactoring | Databases Due to variations in data types and SQL syntax, the following databases are currently supported out of the box. Additional databases as well as enhancements to support for the below databases are available through Liquibase extensions Please find further information about which JDBC driver, URL, classes etc. these databases need, by clicking on the database-specific links in the table below. As of Liquibase v3.1, support for some less common databases has been moved out of Liquibase core and into extensions. To re-enable support for these databases, install the corresponding extension: Since Liquibase is built on top of standard JDBC, the only ties it has to the underlying database is through the SQL that can vary from DBMS to DBMS. You may also run into problem with the SQL generated by the change/refactoring tags on unsupported databases. If, for some reason, the DatabaseChangeLog table cannot be created on your database, the base creation SQL that you can modify to suit your needs is:

Spring Data Graph with Neo4j Support Spring Data Neo4J offers advanced features to map annotated entity classes to the Neo4j Graph Database. The template programming model is equivalent to well known Spring templates and builds the basis for interaction with the graph and is also used for the advanced repository support. Spring Data Neo4j is part of the Spring Data project which aims to provide convenient support for NoSQL databases. Features Quick Start Example @NodeEntitypublic class Movie { @GraphId Long id; @Indexed(type = FULLTEXT, indexName = "search") String title; Person director; @RelatedTo(type="ACTS_IN", direction = INCOMING) Set<Person> actors; @RelatedToVia(type = "RATED") Iterable<Rating> ratings; @Query("start movie=node({self}) match movie-->genre<--similar return similar") Iterable<Movie> similarMovies;} Repositories Declare a repository interface Activate Spring Data Neo4j repositories Use the repository

Database Refactoring | Bestpractices This page describes a number of best practices that you can apply on your project. Organizing your changeLogs The most common way to organize your changelogs is by major release. Directory Structure com example db changelog db.changelog-master.xml db.changelog-1.0.xml db.changelog-1.1.xml db.changelog-2.0.xml DatabasePool.java AbstractDAO.java db.changelog-master.xml The master.xml includes the changelog for the releases in the correct order. The db.changelog-master.xml is the changelog you pass to all Liquibase calls. Managing Stored Procedures Try to maintain separate changelog for Stored Procedures and use runOnChange=”true”. One Change per ChangeSet As far as possible, Avoid multiple changes per changeset to avoid failed autocommit statements that can leave the database in an unexpected state. ChangeSet Ids Choose what works for you. Document ChangeSets Use <comments> in the change sets. Always think about rollback Reference Data Management Leverage Liquibase to manage your Reference Data.

Gephi, open source graph visualization Database Refactoring | Faq What license is Liquibase released under? Liquibase is released under the Apache License, version 2.0. Where can I get the source code? The source is available from the main download page How does Liquibase compare to tools that compare development database with production databases to generate change lists? Liquibase works better because it understands what the changes are. What if multiple processes/application servers attempt to migrate the database at the same time? Liquibase uses a distributed locking system to only allow one process to update the database at a time. Does Liquibase work with branches? Yes. Why do I have to specify an “author” tag? Why not just an “id” tag? What if I really don’t want to specify an author tag? There are times an organization would not want to have changes tied back to a particular individual or if the original author isn’t actually known. How can I specify vendor specific features such as ENGINE=InnoDB in MySQL?

Search Engine Colossus Liquibase Database Refactoring | Liquibase Quickstart Step 1: Create a Changelog File: The database changelog file is where all database changes are listed. It is XML based, so start with an empty XML file: Step 2: Add a ChangeSet Each change set is uniquely identified by an “id” attribute and an “author” attribute. Think of each change set as an atomic change that you want to apply to your database. Step 3: Run the ChangeSet There are many ways to execute your change log including via command line, Ant, Maven, Spring, a servlet listener, and a CDI Environment. Here is an example for mysql via jdbc: liquibase --driver=com.mysql.jdbc.Driver \ --classpath=/path/to/classes \ --changeLogFile=com/example/db.changelog.xml \ --url="jdbc: \ --username=user \ --password=asdf \ migrate There are many more databases supported by liquibase. Step 4: Check Your Database You will see that your database now contains a table called “department”. Next Steps This quick-start guide is designed to get you started with Liquibase.

Database refactoring A database refactoring is a simple change to a database schema that improves its design while retaining both its behavioral and informational semantics. A database refactoring is conceptually more difficult than a code refactoring; code refactorings only need to maintain behavioral semantics while database refactorings also must maintain informational semantics.[1] The process of database refactoring is the act of applying database refactorings to evolve an existing database schema (database refactoring is a core practice of evolutionary database design). You refactor a database schema for one of two reasons: to develop the schema in an evolutionary manner in parallel with the evolutionary design of the rest of your system or to fix design problems with an existing legacy database schema Database refactoring does not change the way data is interpreted or used and does not fix bugs or add new functionality. Tools[edit] LiquiBase See also[edit] References[edit] External links[edit]

Related: