Upgrade to Pro — share decks privately, control downloads, hide ads and more …

cosee TechTalks - Liquibase - flüssige Continuous Delivery inklusive Datenbank

cosee TechTalks - Liquibase - flüssige Continuous Delivery inklusive Datenbank

Continuous Delivery liefert Features kontinuierlich in den Betrieb aus. Damit dieser Mechanismus funktioniert, ist es üblich Programmcode durch Unit Tests zu testen und alle Artefakte in einem automatisierten Prozess zu bauen und zu deployen. Funktioniert dieses Vorgehen für Java-Code etc. sehr gut, wird die relationale Datenbank oft recht stiefmütterlich behandelt. Mit Werkzeugen wie Liquibase ist es möglich, Datenbanken flüssig in den Continuous-Delivery-Prozess zu integrieren.

Konstantin Diener

October 27, 2016
Tweet

More Decks by Konstantin Diener

Other Decks in Programming

Transcript

  1. • Multiple developers • Multiple database types (MySQL, PostgreSQL, Oracle,

    Sql Server, DB2, Derby, HSQL, H2, SQLite, …) • XML, YAML, JSON and SQL formats • Run through your build process, embedded in your application or on demand • Java APIs for executing and embedding www.liquibase.org Apache 2.0 License
  2. <databaseChangeLog>
 
 <changeSet id="1" author="kdiener">
 <createTable tableName="BOOK">
 <column name="id" type="bigint"

    autoIncrement="true">
 <constraints primaryKey="true" nullable="false"/>
 </column>
 </createTable>
  3. <databaseChangeLog>
 
 <changeSet id="1" author="kdiener">
 <createTable tableName="BOOK">
 <column name="id" type="bigint"

    autoIncrement="true">
 <constraints primaryKey="true" nullable="false"/>
 </column>
 </createTable>
  4. <databaseChangeLog>
 
 <changeSet id="1" author="kdiener">
 <createTable tableName="BOOK">
 <column name="id" type="bigint"

    autoIncrement="true">
 <constraints primaryKey="true" nullable="false"/>
 </column>
 </createTable>
  5. --liquibase formatted sql --changeset kdiener:1 CREATE TABLE book ( id

    BIGINT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id) );
  6. @Entity
 public class User {
 
 @Id
 @GeneratedValue
 private Long

    id;
 
 private String username; private boolean locked; 
 @OneToMany(mappedBy = "user")
 private List<Loan> loans = new ArrayList<>(); }
  7. @Entity
 public class User {
 
 ...
 
 @Column (unique

    = true) private String username; private boolean locked; 
 @OneToMany(mappedBy = "user")
 private List<Loan> loans = new ArrayList<>(); }
  8. @Entity
 public class User {
 
 ...
 
 @Column (unique

    = true) private String username; private boolean locked; ... 
 @ManyToOne
 private Language language; }
  9. @Entity
 public class Book {
 
 @Id
 @GeneratedValue
 private Long

    id;
 
 private String title; 
 @ManyToMany
 private List<Author> authors; }
  10. Nächster Talk … Lightning Talks 24. November 2016 > blog.cosee.biz

    > talks.cosee.biz > @coseeaner > #coseetechtalks Bildnachweise: • Monitor: http://www.shutterstock.com/ gallery-831844p1.html • iPhone 6 - Pixeden. http://www.pixeden.com/psd- mock-up-templates/iphone-6-psd-vector-mockup. CC 3.0