The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

dakbari (34) [Avatar] Offline
#1
Hi Chris,

schema evolution while maintaining the data in a schema. In a productive and also in a development environment I always end up in a mess when it comes to guarantee the data in one schema to be the same after the schema evolves, due to domain model changes.

In Chapter 4 you explain how to cope with keeping the schema and the domain model in sync and that tests are an essential part in that.

For each new field that becomes added to my domain model, a new column will be added to my schema (fortunately the ORM is doing that). Nevertheless I must take care that these new columns are not empty.

Hence I always have to run SQL to be sure that these new columns are filled with some default values, so that no NULL POINTER EXCEPTION or the like will be thrown.

Do you describe this topic somewhere in your book or what are your thoughts?

Regards,
Darya
ceracm (113) [Avatar] Offline
#2
Re: Schema Evolution and Maintaining Data
Darya,

This is an interesting issue.

In a development environment I like to use an in-memory DB whenever possible, which makes it easy and fast to rebuild the schema and thereby avoid this problem.

Adding non-null columns can create issues when changing a long-lived/disk-based schema. In a development environment I've often just rebuilt the schema.

If this is not possible because its too time consuming or its a production DB (with real data that you can't discard) then you need SQL scripts to migrate the schema and the data. Oracle and tools such as CA Erwin have support for generating migration scripts. Or you can just write you own.

Chris
dakbari (34) [Avatar] Offline
#3
Re: Schema Evolution and Maintaining Data
Hi Chris,



is there anything you can recommend concerning writing your ownSQL migration scripts B-) ?



Anything like a good book, best practices, your own methods, etc.



Regards,



Darya