managing changes to ezpublish database

40
Visuel à insérer ici EZ CONFERENCE 2016 PARIS Managing Changes to the Database Across the Project Life Cycle

Upload: gaetano-giunta

Post on 09-Jan-2017

237 views

Category:

Internet


1 download

TRANSCRIPT

Page 1: Managing changes to eZPublish Database

Visuel à insérer ici

EZ CONFERENCE 2016PARIS

Managing Changes to the Database Across the Project Life Cycle

Page 2: Managing changes to eZPublish Database

WHO AM IThe short version

• « the guy who has written a lot of answers on the eZPublish forums »

• Working at Kaliop in London since 2014

• Principal consultant at eZ Systems for 7 years

• Love coffee and bicycles ?

• @gggeek

VOTRE SCHEMA

Page 3: Managing changes to eZPublish Database

WHAT THIS TALK IS ABOUTThe short version, too

Page 4: Managing changes to eZPublish Database

Database vs. cms vs. the project lifecycle

01

Page 5: Managing changes to eZPublish Database

Project life cycle

• Development

• Testing

• Maintenance

Page 6: Managing changes to eZPublish Database

Development phase

• Only one source of data: the “dev” db

• Size of data set is generally small

• Changes to content structure are frequent

• Developers need to share the database (mostly the structure)

Page 7: Managing changes to eZPublish Database

Testing phase

• Two sources of data: the “dev” and “test” db

• Size of data set can be small or not

• Changes to content structure are less frequent

• Developers need to share the dev database

• Controlled releases of changes from dev to test

• The bulk of test “content” is not overwritten

Page 8: Managing changes to eZPublish Database

Maintenance phase

• 3 (or more) sources of data: the “dev”, “test” and “prod” db

• Size of data set can be large

• Changes to content structure are infrequent

• Few developers need to share the dev database

• Controlled releases of changes

• Content might flow the opposite way thanchanges to structure:

“copy prod to test”

Page 9: Managing changes to eZPublish Database

What we learned

• Different needs during different phases of the project

• Changes to Content and to Content-structure have different flows

Page 10: Managing changes to eZPublish Database

What the CMS brings in

• Content structure can be modified via the GUI!

• Many tables, with many relations

• No foreign keys

(import scripts can break referential integrity)

• Some data is tied to files stored on disk (take care when

doing backups!)

• Impossible to replicate / sync single tables

Page 11: Managing changes to eZPublish Database

Is it all for the better?

• Easy to deploy changes to Content Structure after go live

Unless the changes takes hours to apply

Will never cover 100% of the cases

• Hard to automate

• Hard to verify

Page 12: Managing changes to eZPublish Database

Managing database changes

A. I connect to the Admin Interface

B.A solved problem02

Page 13: Managing changes to eZPublish Database

Keeping Databases in sync

Many possibilities:

A. All developers connect to the same db

B. Managing changes manually

C. The database is committed to git

D. Managing changes via scripts

E. Live DB replication (really ???)

F. More ?

Page 14: Managing changes to eZPublish Database

A single, shared database

A

Page 15: Managing changes to eZPublish Database

Connecting to a shared database

• good for teams which are *not* geographically distributed

• works when developers do not blow up the database with junk content: needs some developer discipline

• works only up to the 1st deployment to TEST env; then 2 dbs have to be managed anyway

Page 16: Managing changes to eZPublish Database

Manual change control

B

Page 17: Managing changes to eZPublish Database

Managing database changes manually

• Changes to be applied are documented and applied via GUI

• Most Unsafe Option (TM)

• Some tools to help you to keep mental sanity:

ggsysinfo

ezdbintegrity

Page 18: Managing changes to eZPublish Database

ggsysinfohttps://github.com/gggeek/ggsysinfo

• Legacy Extension (no eZPlatform version yet)

• Allows to export in a format easy to diff:

Content Types definitions

Roles and Policies definitions

Workflows and Triggers

Page 19: Managing changes to eZPublish Database

ggsysinfohttps://github.com/gggeek/ggsysinfo

Page 20: Managing changes to eZPublish Database

ggsysinfohttps://github.com/gggeek/ggsysinfo

Page 21: Managing changes to eZPublish Database

ggsysinfohttps://github.com/gggeek/ggsysinfo

Page 22: Managing changes to eZPublish Database

ezdbintegrityhttps://github.com/gggeek/ezdbintegrity

• Legacy Extension (no eZPlatform version yet)

• Allows to verify consistency of data in the database:

Foreign keys

Content fields

Orphaned storage files

Custom rules added by the end user

• No GUI

Page 23: Managing changes to eZPublish Database

ezdbintegrityhttps://github.com/gggeek/ezdbintegrity

Page 24: Managing changes to eZPublish Database

ezdbintegrityhttps://github.com/gggeek/ezdbintegrity

Page 25: Managing changes to eZPublish Database

Database as source code

C

Page 26: Managing changes to eZPublish Database

Committing the database to git

• good for when the development database does not contain a huge number of contents and assets

• good for when the development database does not change too frequently

• developers might be working on different versions of the db: needs some developer discipline

• works only up to the 1st deployment to UAT env; then 2 dbs have to be managed anyway

Page 27: Managing changes to eZPublish Database

Committing the database to gitTIPS

• Database export/import scripts have to developed

• Good idea: remove temporary data before export

• Bad idea: hardcode database passwords in the scripts

• Good idea: read the db passwords from the ezpublish configuration

“Kaliop eZPublish 5 installer”

• Good idea: have the script manage binary contents & clear caches

ex: github.com/kaliop-uk/websummercamp2016/tree/master/site/bin

Page 28: Managing changes to eZPublish Database

Automated change control

D

Page 29: Managing changes to eZPublish Database

Managing database changes via script

• Safest option

• Good for when the development database does not change too frequently

• Perfect after deployment to TEST/PROD

• kaliop/ezmigrationbundle

Page 30: Managing changes to eZPublish Database

eZ Migration Bundlehttps://github.com/kalipo-uk/ezmigrationbundle

• An eZPublish 5 bundle (no support for pure Legacy mode)

• Allows to define “migrations”

• Each migration is a set of changes to the DB – content or structure

• Migrations are stored as part of the application source code

• A console command is used to execute them

• A custom table in the db stored information on already executed ones

Page 31: Managing changes to eZPublish Database

An example migrationhttps://github.com/kalipo-uk/ezmigrationbundle

Page 32: Managing changes to eZPublish Database

What types of migrations are supportedhttps://github.com/kalipo-uk/ezmigrationbundle

• creation, update and deletion of Contents• creation, update and deletion of Locations• creation, update and deletion of Users• creation, update and deletion of UserGroups• creation, update and deletion of Roles• creation, update and deletion of ContentTypes• creation and deletion of Languages• creation of Tags (from the Netgen Tags Bundle)

Page 33: Managing changes to eZPublish Database

Cool features Ihttps://github.com/kalipo-uk/ezmigrationbundle

• Well documented (*)

• Stable: functional tests are run on Travis

• Future proof: based on the eZPublish Public API

* = opinions may vary

Page 34: Managing changes to eZPublish Database

Cool features IIhttps://github.com/kalipo-uk/ezmigrationbundle

• Supports ids, identifiers and remote-ids to match elements

• Supports the concept of ‘references’ to anything which has just been created/updated

• Update and delete operations can affect a whole set of elements in a single pass

Page 35: Managing changes to eZPublish Database

Cool features IIIhttps://github.com/kalipo-uk/ezmigrationbundle

For more complex needs, two types of custom migrations:

• SQL files

• PHP classes with a simple Interface

Fully extensible using standard Symfony mechanisms

• Event listeners

• Tagged services

• Service definition takeover

Page 36: Managing changes to eZPublish Database

Demo time

03

Page 37: Managing changes to eZPublish Database

Going forward

04

Page 38: Managing changes to eZPublish Database

Version 3 released today!https://github.com/kalipo-uk/ezmigrationbundle

If the demo effect does not strike now…

Page 39: Managing changes to eZPublish Database

Is your favourite feature missing?https://github.com/kalipo-uk/ezmigrationbundle

The first brick is laid, many scenarios are possible

ex: allow a full ETL process / migrate across eZ installations

Feature requests and Bugs are managed on Github

Pull Requests are welcome

(thanks Lolautruche!)

Page 40: Managing changes to eZPublish Database

THANK YOU

@gggeek

https://github.com/kaliop-uk

https://github.com/kaliop

http://www.kaliop.co.uk/info/ez.html