02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH
DB Transformation und Migration
Pedro Lafuente Blanco
tarent Solutions GmbH
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
02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH
Pedro Lafuente Blanco
tarent Solutions GmbH
02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 2 von 22
– Liquibase – flyway
– ServletListener – Spring
02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 3 von 22
DEV v1.1 v1.2 ? QS v1.1 v1.0 Spezifikation
v1.1 v1.0 v1.0
02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 4 von 22
Breite DB Unterstützung Integration in unsere Toolchain Graphische Modellierung der Änderungen Rollback Unterstützung (unmittelbar und später) Vereinfachung
Versionsverwaltung & Protokolle
02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 5 von 22
c5-db-migration
02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 6 von 22
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
02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 8 von 22
02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 9 von 22
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
02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 12 von 22
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
02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 13 von 22
<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
02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 14 von 22
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)
02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 15 von 22
Strengths Weaknesses
„dependency trees“ benutzt werden
„dependency tree“
Metadatentabelle abgebildet
Integration
aktiv ist
z.B: triggers,procedures und packages.
nur einem Fileset könnte Fehler anfällig sein. Oportunities Threats
02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 16 von 22
Strengths Weaknesses
Migrationen
erkannt
„dependency trees“ zu bauen, ohne Dateien zu duplizieren.
kleinere Projekte
neuzuschreiben Oportunities Threats
02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 17 von 22
Könnte das Skript-per-DBMS Problem lösen
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
02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 18 von 22
XML db.tarentX.a.xml aenderungen.sql SQL
02.04.12 | Pedro Lafuente Blanco – tarent Solutions GmbH 19 von 22
p.lafuente@tarent.de