How to automate my relational database operations using ci/cd and gitlab?

Viewed 93

I want to automate my RDB. I usually use SQLDeveloper to compile, execute and save my PL SQL scripts to the database. Now I wish to build and deploy the scripts directly through gitlab, using ci/cd pipeline. I am supposed to use Oracle Cloud for this purpose. I don't know how to achieve this, any help would be greatly appreciated.

Requirements: Build and deploy PL-SQL scripts to the database using gitlab, where the password and username for the database connection are picked from vault on the cloud, not hardcoded. Oracle cloud should be used for the said purpose.

If anyone knows how to achieve this, please guide.

2 Answers

There are tools like Liquibase and Flyway. Those tools do no do miracles. Liquibase has a list of changes (XML or YAML) to be applied on a database schema (eventually with undo step).

Then it has a journal table in each database environment, so i can track which changes were applied and which were not.

It can not do mighty schema comparisons like SQL Developer or Toad does. It also can not prevent situations where applied DML change on prod database goes kaboom, because the DML change was just successfully tested on 1000x smaller data set.

But yet it is better than nothing and it can be integrated with ansible/gitlab and other CI/DC tools.

You have a functional sample, using Liquibase integration with sqlcl in my project Oracle CI/CD demo.

To be totally honest

  • It's a little out-of-date, because I use a trick for rollback because in the moment of writting, Liquibase tagging was not supported. Currently it's supported
  • The final integration with Jenkins is not done, but it's obvious
Related