Pergunta

We are working on one legacy framework and it is continuously evolving.

Problem 1 : If somebody want to run the application with latest code then he/she spend lots of time in doing so (like somebody forgets to commit code or commits partial code).

Solution : We started using Jenkins and integrated it with our SVN repository with it. So now we always have working code. We thought, now anyone(especially new developer) can get started with application in very short time.

Problem 2 : Soon we discovered that its not code but changes in database(like adding new table or altering existing table or changes in database bootstrap script) that takes developers time.

My question is, how can I deploy code changes (which currently, I am able to do) as well as database changes (which I don't know how can be done) to some test server using some automation tool like Jenkins.

Foi útil?

Solução

The approach that seems to be the most common is to create a table in the database which keeps track of the version of a schema and reference data. This version is not to be confused with the version of the DBMS. Then you create scripts which incrementally modify the schema and update that table. Getting from version a to version c a matter of running the scripts for b then c which can be automated fairly easily.

I would also advise that you add checks in your code that verify the schema version on startup and fail-fast if it is not in-sync.

There are tools such as flyway that implement this strategy and you should look at them before embarking on creating something yourself.

Outras dicas

My team is currently looking at RedGate's SQL Change Automation tool for continuous integration/deploy of database changes. It appears to be the only ready-for-prime-time answer to CI/CD of databases, although it's of course possible we missed others.

We have also used SQL SSDT, it's not exactly CI/CD but it significantly reduces the pain of creating DB deploy scripts. (I believe MS actually absorbed SSDT from a RedGate product.)

Licenciado em: CC-BY-SA com atribuição
scroll top