DB Transformation und Migration Pedro Lafuente Blanco tarent - - PowerPoint PPT Presentation

db transformation und migration
SMART_READER_LITE
LIVE PREVIEW

DB Transformation und Migration Pedro Lafuente Blanco tarent - - PowerPoint PPT Presentation

DB Transformation und Migration Pedro Lafuente Blanco tarent Solutions GmbH 02.04.12 | Pedro Lafuente Blanco tarent Solutions GmbH Agenda Problemstellung / Anforderungen Kandidaten Liquibase flyway Tests/Use Cases


slide-1
SLIDE 1

02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH

DB Transformation und Migration

Pedro Lafuente Blanco

tarent Solutions GmbH

slide-2
SLIDE 2

02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 2 von 22

Agenda

Problemstellung / Anforderungen Kandidaten

– Liquibase – flyway

Tests/Use Cases

– ServletListener – Spring

Empfehlung Q&A

slide-3
SLIDE 3

02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 3 von 22

Problemstellung

DEV v1.1 v1.2 ? QS v1.1 v1.0 Spezifikation

X

v1.1 v1.0 v1.0

slide-4
SLIDE 4

02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 4 von 22

Anforderungen

Breite DB Unterstützung Integration in unsere Toolchain Graphische Modellierung der Änderungen Rollback Unterstützung (unmittelbar und später) Vereinfachung

.log

Versionsverwaltung & Protokolle

slide-5
SLIDE 5

02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 5 von 22

Kandidaten

c5-db-migration

mybatis

MIGRATEdb

migrate4j

dbmaintain

AutoPatch Tarantino

DBDeploy

solidbase

flyway

liquibase

slide-6
SLIDE 6

02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 6 von 22

  • XML Delta-Skipte (unterstützt auch SQL)
  • JDBC-basiert
  • Maven-Plugin, CLI, Java API, Spring, Grails
  • Erzeugt Rollback-Skripte für viele SQL-Funktionen
  • Änderungen und Version in Metadatentabelle

abgebildet

  • ServletListener Unterstützung
  • Cluster-Safe
  • Erweiterbar
slide-7
SLIDE 7

02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 7 von 22

XML db.tarentX.a.xml db.tarentX.b.xml XML db.tarentX.c.xml XML aenderungen.sql SQL XML db.tarentX.v1.1.xml XML db.tarentX.master.xml XML db.tarentX.v1.2.xml XML

slide-8
SLIDE 8

02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 8 von 22

Liquibase XML

slide-9
SLIDE 9

02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 9 von 22

  • SQL-basiert
  • JDBC-basiert
  • Maven-Plugin, CLI, Java API
  • Änderungen und Version in Metadatentabelle

abgebildet

  • Cluster-Safe
  • „It just works“
slide-10
SLIDE 10

02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 10 von 22

SQL V1__Base.sql V1_2__AenderungenTableA.sql SQL V1_1__AenderungenTableB.sql SQL V1_3__AddingUsers.sql SQL

NewTables Base Records

V1 V1.1 V1.2 V1.3

slide-11
SLIDE 11

02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 12 von 22

Testphase

Typ Beschreibung Kurze B.

1 DB-Snapshot erzeugen Snapshot Erzeugen 2 Feld employees.testfield (integer) hinzufügen. Feld hinzufügen ... ... ... 5 Feld employees.emp_no entfernen PK/FK entfernen ... ... ... 9 departments.dept_name tmanuel ändern, so dass ein Datensatz die 20char. überschreitet. departments.dept_name von varchar(40) in varchar(20) umwandeln Datentyp ändern (notok) ... ... ... 13 dummytable.number von double in varchar(40) umwandeln Datentyp ändern 14 Feld dummytable.fkemp hinzufügen, und eine Foreing-Key- Beschränkung auf employee.emp_no festlegen. Dabei Rollback- Script erzeugen. Rollback-Script ausführen. Rollback

slide-12
SLIDE 12

02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 13 von 22

ServletListener (externes .war)

<Context> <Resource name="liquibase/postgresdb" auth="Container" type="javax.sql.DataSource" username="dbmgr" password="superSecret" driverClassName="org.postgresql.Driver" url="jdbc:postgresql://dbserver/tarentx" maxActive="8" maxIdle="4"/> </Context> <context-param> <param-name>liquibase.changelog</param-name> <param-value>de.tarent.tarentx.db-master.xml</param-value> </context-param> <context-param> <param-name>liquibase.datasource</param-name> <param-value>java:comp/env/liquibase/postgresdb</param-value> </context-param> <listener> <listener-class> liquibase.integration.servlet.LiquibaseServletListener </listener-class> </listener>

web.xml context.xml sql/xml + liquibase.jar im classpath

+ +

slide-13
SLIDE 13

02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 14 von 22

Spring (im selben .war)

applicationContext.xml sql/xml + liquibase.jar im classpath

+

<bean id="liquibase" class="liquibase.integration.spring.SpringLiquibase"> <property name="dataSource" ref="dataSource" /> <property name="changeLog" value="classpath:liquibase/db-master.xml" /> </bean>

(dataSource wurde vordefiniert)

slide-14
SLIDE 14

02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 15 von 22

SWOT

Strengths Weaknesses

  • ServletListener-Unterstützung
  • Kein DBMS-spezifisches SQL
  • Delta-Dateien können in verschiedenen

„dependency trees“ benutzt werden

  • Snapshots
  • „Future rollback“ Skripte
  • <include>-Tags benötigt für

„dependency tree“

  • Proprietäres XML
  • Fehlerhafte Updates werden nicht in

Metadatentabelle abgebildet

  • Automatisierung durch Hibernate-

Integration

  • Versionverzweigung
  • Einige Bugs, obwohl Entwicklung ziemlich

aktiv ist

  • Exportiert nicht alle Objekte:

z.B: triggers,procedures und packages.

  • Versioning für verschiedene DBMS mit

nur einem Fileset könnte Fehler anfällig sein. Oportunities Threats

slide-15
SLIDE 15

02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 16 von 22

SWOT

Strengths Weaknesses

  • Protokolliert auch nicht erfolgreiche

Migrationen

  • Flexibles „Version numbering“
  • Abhängigkeiten werden automatisch

erkannt

  • Keine Möglichkeit, verschiedene

„dependency trees“ zu bauen, ohne Dateien zu duplizieren.

  • DBMS spezifische SQL !
  • Keine „future rollback“ Skripte
  • Keine Snapshots
  • Narrensichere Implementierung für

kleinere Projekte

  • Alle Deltas für verschiedene DBMS

neuzuschreiben Oportunities Threats

slide-16
SLIDE 16

02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 17 von 22

Könnte das Skript-per-DBMS Problem lösen

  • Evtl. mehr Arbeit auf Grund des XML

Erleichtert Installation & Initialisierung, auch bei Servlets Besser für größere Projekte, wo sich der Verwaltungsaufwand lohnt Löst nicht das Skript-per-DBMS Problem Würde nicht bei Downgrades helfen Kleiner Fortschritt im Vergleich zum Status Quo Besser für kleinere Projekte, die DB-Versionsverwaltung nutzen wollen

Empfehlung

slide-17
SLIDE 17

02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 18 von 22

.log

XML db.tarentX.a.xml aenderungen.sql SQL

Q&A

?

slide-18
SLIDE 18

02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 19 von 22

¡Muchas gracias!

p.lafuente@tarent.de