How to Pull/Push using Gitora

Gitora enables Oracle developers to pull code from other databases managed by Gitora with a single click. It also enables them to push to and pull from other Git repositories including the ones hosted by GitHub, GitLab, Bitbucket etc…

Below are the steps to achieve this:

Moving Code from one Database to Another Using Gitora

Gitora 5 can manage any number of databases. It also enables these databases to pull code from each other. This makes moving code in your delivery pipeline (from dev to test, from test to preprod etc…) much less error prone and easier.

Open the Gitora app. Select the repo you want to pull to from the main select box.

In order pull code from another database managed by Gitora, click the “Git->Other Databases -> Pull” menu item. The Pull Dialog shows up.

Select the database you want to pull from. Next choose a repo and the branch.

In the example above, we are connected to our TEST database. We are pulling from the DEV database the MyNewRepo repo’s master branch. Any code changes that exist in the database objects that are part of MyNewRepo’s master branch (but don’t exist in TEST) will move to the TEST database after clicking the Pull button.

Pull is the simplest and most common use case. It moves the latest version of a code base from one database to another. Gitora also supports more sophisticated workflows. For example, you can move the code at a specific commit ID on a specific branch from one database to another database.

To achieve this click “Git->Other Databases->Fetch and Merge” menu item. The Fetch and Merge Dialog shows up. To further extend the example above, using this dialog, you can specify which commit ID you want to fetch from the other database. The example below fetches and earlier commit ID from the MyNewRepo’s master branch in DEV. (Pull always fetches the current code in the DEV database.)

Finally, we may want to fetch a new branch in another database that does not exist in the database we are connected to. For example, we may want to test a new feature developed in the feature branch FEATURE1. To test this feature, we need to pull it to the TEST database. To achieve this, click “Git->Other Databases-> Switch to Branch in Another Database” menu item. A Dailog shows up. Enter the database, repo and the branch name you want to bring over to the database you are connected to. In the example above, we are brining the FEATURE1 branch from MyNewRepo in DEV to the TEST database.

Pull from/Push to Remote Repos

In the Gitora web application, click the Settings –> Manage Remote Repos from the menubar.

The Manage Remote Repos page shows up.

Remote Git Repositories Dialog

Click the add button. The Add Remote dialog shows up. Enter a friendly alias for the remote Git repo. Finally, enter the URL that points to the remote repo. If you are using a service like GitHub, refer to the service provider website for the correct URL. For GitHub, the URL is in the following format:[github user name]/[gitreponame].git

Moving Code from Remote Repos to Databases using Gitora

Pulling from remote repos work the same way as pulling from other databases. Please note that in order for Gitora to successfully pull from a remote repo and update the database the structure, the remote repo must be either created by Gitora initially or the structure, folder and file names of the repo must be as if they are created by Gitora.

Pushing to a remote Git Repo

Open the Gitora app, select the repo you’d like to push from the main select box. Netx, click Git->Remote->Push. The Push dialog shows up.

The Push Dialog

Select the branch you’d like to push and the target remote repository you’d like to push this branch to. Enter the user name and password to connect to the remote repository. Leave these fields empty if the remote repository is not protected by a user name and a password. For example, if you are pushing to GitHub, the credentials you should enter are your GitHub user name and password.

Click the push button and wait for the response message to show up.

Introducing Gitora 3, version control for the Oracle Database

Today, we’re happy to announce the general availability of Gitora 3.

Gitora 2 enabled developers to manage database objects that support the CREATE OR REPLACE command, namely PACKAGES, PROCEDURES, FUNCTIONS, TRIGGERS, VIEWS, SYNONYMS and TYPES in a Git repository. (In Gitora terminology, we call these “Soft Objects”).

Gitora 3 goes a step further and enables developers to manage every database object in an Oracle Database with Git even if the object does not support the CREATE OR REPLACE command. (In Gitora terminology, we call these “Hard Objects”.)

Specifically, Gitora 3 allows developers to manage TABLES, INDEXES, SEQUENCES, CONSTRAINTS, TABLESPACES, MATERIALIZED VIEWS and every other schema or non-schema objects with Git.

Let’s examine how you can manage these objects with Gitora 3 with an example.

Introducing Managed Schemas

Gitora 3 introduces the concept of a Managed Schema. A managed schema is an Oracle Database Schema that Gitora tracks for execution of Hard Object DDL’s. In other words, you register one or more Oracle Schemas to a Gitora repository. Once a schema is registered to a repository, Gitora will track every hard object DDL executed for that schema. A repository can manage many schemas but a schema can only be managed by one repository.

Adding A Managed Schema to a Gitora Repository

In the Gitora App, select a repository. Click Local Commands –> Add/Remove Managed Schemas menu option. A dialog shows up.

Select the schema(s) you’d like to manage.

Click OK. The dialog closes. The screenshots above show the HR schema being added to a repo as a managed schema.

The Model Package

After a schema becomes managed, Gitora creates a new package in the schema automatically. This package is always called GITORA_MODEL[X] where [X] is a unique number that identifies the package. In our example above, Gitora created the GITORA_MODEL1 package in the HR schema and added this package to the Git repository which is managing the HR schema:

The screenshot above tells us that repo1 is managing the HR schema.

Tracking Soft Objects

There are no changes in Gitora 3 for soft objects. You continue managing soft objects just like you’ve been managing them with Gitora 2. In other words, any repo can manage any number of soft objects and any number of schemas.

To demonstrate this let’s add a dummy package called PACKAGE1 to HR and manage it with the same repo named repo1:

Select Local Commands –> Add/Remove Soft Objects menu item. A dialog shows up where you can select which soft objects you’d like to manage with repo1. Note that, GITORA_MODEL1 package shows up as a managed package because it was automatically created to manage the hard objects in the HR schema. 

Add PACKAGE1 as a managed package and click OK. The Gitora App shows the following object list for repo1:

Tracking Hard Object DDL’s

Let’s execute the following DDL statements for the HR schema: (Note that in the database session we first have to log in to Gitora with a valid Gitora user. In this case, we logged in as admin.)




Finally, let’s also modify a soft object and add a new dummy function to PACKAGE1 called function1.

To commit our changes, let’s switch to Gitora App and click the commit button. The My Objects Dialog shows up, displaying the list of soft objects and hard object DDL’s ready to be committed to Git. Note that the dialog only shows the changes made by the signed in developer:

In this dialog, you can choose which packages or hard object DDL’s you’d like to include in this commit by checking/unchecking the checkbox in the Include? columns of both grids.

Note that, the commit registers the package update and the table DDL statement as a single logical commit which is a key benefit we’d like to get from the version control system.

After the commit, we receive the following message from Git:

Note that, the Git commit not only included PACKAGE1 but also the GITORA_MODEL1 package. After the Git commit is successful, the new GITORA_MODEL1 package code looks like this:

PACKAGE BODY gitora_model1 IS 

function doModel return clob is
  v_log_cl clob;
  v_ddl_cl clob;
  v_cursor_int integer;
  return_value integer;
  procedure log(in_text_cl clob) is
  /*SCRIPT FOR HR.COUNTRIES by user:admin */
    execute immediate v_ddl_cl;
    log('DDL executed successfully.');
    when others then
      log('ERROR:'||' '||SQLErrm||' '||dbms_utility.format_error_backtrace);
  /*SCRIPT FOR HR.EMPLOYEES by user:admin */
   ADD (
    execute immediate v_ddl_cl;
    log('DDL executed successfully.');
    when others then
      log('ERROR:'||' '||SQLErrm||' '||dbms_utility.format_error_backtrace);
  /*SCRIPT FOR HR.COUNTRIES by user:admin */
   ADD (
    execute immediate v_ddl_cl;
    log('DDL executed successfully.');
    when others then
      log('ERROR:'||' '||SQLErrm||' '||dbms_utility.format_error_backtrace);
  return v_log_cl;


The GITORA_MODEL packages contain the DDL statements you commit to your Git repository for the schema they are in. You can edit them any way you’d like to change the DDL statements, call other functions and procedures etc… In other words, they are no different than any other package you are managing with Gitora.

GITORA_MODEL.doModel function executes the DDL statements stored in the package. You can use the doModel function to execute the changes in a target database. For example, after development is completed for a new version, you can pull the new version to from DEV to the TEST database and simply execute the GITORA_MODEL.doModel function to transfer the hard object updates to TEST.

Errors during its execution does not prevent the doModel function from executing remaning DDL statements. The function captures these errors and returns them as a CLOB value. This way, the same GITORA_MODEL package can be executed many times even if contains DDL statements that are previously executed in the target database (because these statements will silently fail). The GITORA_MODEL packages requires minimal maintanance, if any at all.

Non-Schema Objects and GRANTS

Not every database object has a schema. For example, TABLESPACES do not have an owner schema. DDL statements for non-schema objects are tracked by Gitora if the Oracle User(schema) who executed the statement is being managed by Gitora. For example, in the case above, if a DDL statement to create a TABLESPACE is executed by the Oracle User HR, then this DDL will be tracked by repo1.

Similarly, any GRANT and REVOKE statement will be tracked by the Gitora repo which is managing the Oracle User(schema).


You may not want to manage every object or object type with Gitora. Moreover, you may want to define complex rules to decide which object is managed by which repo. Customizing what types of objects Gitora should manage and in which repo is very easy using PL/SQL. Gitora uses four database level DDL triggers to detect DDL statement execution. By editing these triggers, you can define any kind of rule you like.

For example, a common rule used by Gitora customers is to allow developers to create tables for testing purposes. These tables do not need to be managed by Gitora. One of the easy ways of implementing this rule is to tell developers to use a certain prefix such as Z_ for test tables, and exclude any table DDL statement from executing Gitora API’s in the four DDL triggers if the table name starts with Z_.

Existing Customers

Gitora 3 is a free upgrade for all current customers. Please allow us 2-3 weeks to send us your new license scripts.

We’ll have more tutorials and webinars about Gitora 3 in the near future. Now download the Gitora 3 trial and start playing! 🙂

Agile Development with Oracle PL/SQL

This articles is about agile development using multiple (pluggable) databases. If you are trying to implement an agile workflow using a single database please read this article.

Here is the number one question we receive from PL/SQL developers, DBA’s and IT managers who are implementing a version control solution for their Oracle Database:

Developer 1 (or Team 1) works on Feature A (or issue A, bug A, project A). Developer 2 works on Feature B. Both developers make many changes to the PL/SQL code and many commits to the version control repository. We move to testing. Based on the test results, even more commits are made by both developers. Now at the last minute, due to some reason we decide to ship Feature B only. How can we remove Feature A from the source code easily? How does Gitora help in such a situation?

There are multiple answers to this question. Below, I’ll go over two possible solutions for two potential setups:

  1. If you are using one shared development database
  2. If you are using multiple development databases (or at least you are open to the idea.)

If You Are Using One Shared Development Database

Let’s assume that our shared development database is called DEV. In other words, both Feature A and Feature B are being developed in the same code base. Let’s also assume our only test database is called TEST.

Finally, assume that DEV and TEST are managed by Gitora. All version control operations are done with Gitora.

In this case, the commit history of the DEV repo has changes both for Feature A and B in a random order and looks something like this:

There is no easy way to remove the commits for Feature B in this setup. If the team decides to deliver Feature A to production but postpone the delivery of Feature B here are the steps they should follow:

  • Go over the commit history of the DEV repo and find the commits that are related to Feature A.
  • Comment out/revert back/change the edits made for Feature A. Git will help the developers to see what’s changed, added, deleted and what the previous versions of code objects looked like.
  • Commit these new changes to the DEV repo.

At this point the commit history in the DEV repo looks something like this:

And finally, the next steps are:

  • Pull the new version from DEV to TEST.
  • Run tests on the TEST database. If there are no errors, deliver the new version to production. If there are errors, go to the second step, wash, rinse and repeat until the desired outcome is reached.

In such a setup Gitora provides the following benefits:

  • Gitora keeps track of all changes made to the PL/SQL code in the DEV database, automatically. Developers do not have to remember which PL/SQL objects they modified and what they modified in those objects.
  • Moving the code between DEV and TEST is as easy as clicking a button. The team does not need to manually prepare scripts.

The downside of this approach is that it involves manual work which is error prone. Developers still have to manually go through the commit history and make the changes to the source code in DEV to disable/remove Feature A. With only one shared development database, there is no easy way to remove Feature A.

If You Are Using Multiple Development Databases

Now things get more interesting. Below is a simplified workflow that uses only two development databases. This setup enables the IT team to deliver only the Feature B without manually editing PL/SQL code objects to remove Feature A.

Here is our initial set up:

  • Developer 1 works in the database DEV1 and Developer 2 works in the database DEV2 i.e. both developers (teams) have their own private environment while they are developing their respective features.
  • Our only test database is called TEST.
  • All databases are managed by Gitora and all Git command are executed using Gitora.
  • DEV1, DEV2 and TEST start with the same version of the code which is stored in the master branch of their respective Git repositories. (In other words, DEV1/master and DEV2/master are clones of TEST/master)

Developer 1:

  • Create a new branch named featureA (DEV1/featureA). Switch DEV1 to use this new branch.
  • Write code in DEV1
  • Commit code changes to the DEV1/featureA. Go back to step 2 as many times as needed.

As an example, the Git history in Gitora DEV1 looks like this:

Developer 2:

  • Create a new branch named featureB (DEV2/featureB). Switch DEV2 to use this new branch.
  • Write code in DEV2
  • Commit code changes to the repository to DEV2/featureB (using Gitora DEV2). Go back to step 2 as many times as needed.

The Git commit history in Gitora DEV2 looks like this:

Moving Code Between Databases

At any point in time, if Developer 1 or Developer 2 decides to send code to TEST (for example, for integration testing purposes..), they follow the steps below.

Please note that in real world development, the workflows described below can be performed simultaneously in DEV1 and DEV2, in no particular order, any number of times until both features are ready to be deployed to production.

The steps below are merely a simplified example of how this workflow takes place.

Developer 1:

  • In our example , we assume that Developer 1 is the first developer sending her commits to TEST.
  • Merge DEV1/featureA to DEV1/master. (DEV1/featureA –> DEV1/master). After the merge, commit history for DEV1 looks like this:
  • Pull master branch from DEV1 to TEST. (DEV1/master –> TEST/master). A “Pull” is simply a two step process of fetching a branch from a remote Git repository and then merging it to a local branch. In our example TEST fetches DEV1/master from DEV1 and merges it to TEST/master which we simply show as DEV1/master –> TEST/master.

    After the pull, commit history of both TEST and DEV1 looks like this:

Developer 2:

  • Pull master branch from TEST to the master branch in DEV2. (TEST/master –> DEV2/master). (In our example, this is necessary, because TEST/master has received new commits from DEV1/master.) After the pull, the commit history looks like this: (Remember, previously we pulled commits from DEV1/master to TEST/master and we also made commits to DEV2/featureB)
  • Merge DEV2/featureB to DEV2/master. (DEV2/featureB –> DEV2/master) After the merge, the commit history looks like this:
  • Pull master branch from DEV2 to TEST. (DEV2/master –> TEST/master). After the pull, the commit history looks like this:

In other words, in its final state, the source code in the TEST database is a merge of Feature A and B where the commits in TEST/master branch are combined. In our example, the full commit history of DEV1, DEV2 and TEST repositories look like this:

Note that at all times, DEV1/featureA only contains the code for Feature A. Similarly, DEV2/featureB only contains the code for Feature B.

This workflow enables the IT team to exclude Feature A from the next deployment at any point in time before going to production.

Removing Feature A from the Deployment

To achieve this in our example, follow the steps below:

  • Revert DEV2/master back to its initial state where no code for Feature B has been committed yet. (This uses the Git reset command.)
  • Merge DEV2/featureB to DEV2/master. (DEV2/featureB –> DEV2/master)
  • Reset TEST/master to its original state.
  • Finally, pull the master branch of DEV2 to the master branch of TEST. (DEV2/master –> TEST/master)

After these steps are completed, the TEST database only contains code changes related to Feature B. We can use Gitora to extract a DDL script which contains only the changes made between the initial and final state of TEST/master and use this script to deploy the new version which only includes Feature B to the production database.

Gitora helps developers execute this workflow with a point&click GUI. Specifically:

  • Gitora keeps track of all changes made to the PL/SQL code in DEV1, DEV2 and TEST automatically.
  • Gitora updates the source code in the Oracle Database automatically when the executed Git command changes the files in the working directory.


  • Developers don’t have to remember which PL/SQL objects they modified and what they modified in those objects.
  • Moving the code between DEV1, DEV2 and TEST is as easy as clicking a button. The team does not need to manually prepare scripts. Gitora can either generate the scripts or update the databases automatically.
  • Crucially, Gitora enables Developer 1 and Developer 2 to switch between code branches automatically. (For example if the DEV1 database switches from featureA branch to the master branch, Gitora automatically updates the code in the DEV1 database to reflect this change.)

Download Gitora now and try this workflow in your environment.

Gitora in 30 Minutes

Gitora is the version control tool for PL/SQL. It hooks Git to the Oracle Database and enables you to manage your PL/SQL code base easily. Below is a 30 minute demo video which explains the benefits of Gitora and how it works.

Gitora 2.1 is available with tagging support

We are happy to announce that Gitora 2.1 is available for download. Along with a few bug fixes, Gitora 2.1 enables PL/SQL developers to use Git Tags to label any commit point in the Git repository.

Tags can be used for a variety of use cases but the most common one is to label a Commit ID for specific versions of the code base such as tagging a specific commit with the label “Version 2.0”.

It is very easy to create tags in Gitora. Simply, go to the local commands menu, select “Create Tag” menu item under “Tags”.



A dialog shows up.

Create Tag Dialog

Enter the name of your tag (no spaces). Enter the commit ID you’d like to attach it to. If you’d like to attach your tag to the HEAD i.e. the most recent commit in the current branch, leave the Commit ID field empty. You may also use a branch name instead of an actual Commit ID.

Click OK to create the tag. If the tag is attached to a commit visible in the Gitora repository browser, it will show up in the Gitora Application.

Gitora Repository Browser

To delete a tag, select the Delete a Tag menu item under the Tags menu, enter the name of the Tag you’d like to delete and click OK.

Tags are available in Gitora 2.1 Professional Edition. Enjoy! 🙂

Kind Regards,
The Gitora  Team

Gitora Webinar Video and Slides

We hosted a webinar about Gitora last week. It received more than 400 signups and over 120 people have attended the event. The interest to the webinar was so high that we hit the 100 attendee limit of the webinar software we are using. Thanks to everyone who attended and helped us to do a better webinar with their questions and comments.

If you could not make it to the webinar, you can watch it or view the slides below. The webinar consists of two parts. In the first part, we talk about transition strategies to move an organization from manual version control for PL/SQL to version control with Gitora. In the second part, we showed the capabilities of Gitora with a live demo.

Installing Gitora Manually

We created a solid installer for Gitora which has a very high success rate. However, IT environment can be very complex and restrictive (and understandably so). So having an installer does not work for everyone and every organization.

Therefore, today we are making the Gitora 2.0 installation scripts available for download. Below are the steps you can follow to install Gitora 2.0 to your environment manually.

Installation of Middletier Components

  1. For Linux and Mac OS, install Git manually from For Windows, Git is already included to this setup.
  2. Move Gitora2 folder to the place you want to locate Gitora middle tier components.
    e.g /Users/username/
  3. For Windows, open fix_parameters_WINDOWS.bat to edit.
    For Mac OS, open to edit.
    For Linux, open to edit.
  4. Set GITORA_ROOT parameter to the absolute path of the Gitora2 folder from step 1..
    e.g /Users/username/Gitora2
  5. Set GITORA_DATABASE_CONNECTION_STRING parameter to the correct jdbc connection string to your database.
    e.g jdbc:oracle:thin:@
  6. For Mac OS and Linux, set GIT_EXECUTABLE parameter to the path of git executable.
    e.g. /usr/bin/git
  7. Open command line terminal and run fix_parameters_WINDOWS.bat for Windows, for MAC OS, for Linux.

Installation of Database Components

  1. Connect to the Oracle Database with the SYS user
  2. Run 01_SYS.sql
  3. Disconnect from SYS
  4. Connect to the database with the GITORA user
  5. Run 02_GITORA.sql
  6. Ensure that there are no invalid packages in GITORA schema.
  7. Create a row in table GITORA.T_TEMP_APPLICATION
  8. Copy the contents of Gitora.xml to this newly created row
  9. Issue a commit to save this row to the database.
  10. Run 03_GITORA.sql
  11. Disconnect from GITORA user
  12. Connect to the database with SYS user
  13. Open 04_SYS.sql and replace the two occurrences of @VERSIONCONTROL_HOST@ keyword with the IP address of your Gitora middle tier machine, where Gitora web server and middle tier components are installed. You need to ensure that your middle tier machine is accessible from database machine by checking network and firewall settings of both machines.
  14. For Windows, change the value of “folderSeparator” parameter from ‘/’ to ‘\’.
  15. Run 04_SYS.sql
  16. Disconnect from SYS.

Starting Up Gitora

  1. For Windows, run Gitora2/apache-tomcat-7.0.69/bin/startup.bat.
    For Mac OS and Linux, run Gitora2/apache-tomcat-7.0.69/bin/
  2. Open your browser and type http://[MIDDLE TIER IP ADDRESS]:7997/gitora/main.html name=Gitora

Generating a Diff Script with Gitora

Gitora enables developers to move changes between databases with a single click.

Gitora can also be used to generate a DDL script from the Git repository which can be used to synchronize the source code between two databases. For example, this feature can be used to generate a script to syncronize a production database to the latest version of the source code in the pre-prod database. This tutorial explains how to use this feature in Gitora.

Assume that we are connected to the preprod database and would like to generate a sync script to upgrade prod to the same state the preprod database is in.

Open the Gitora Application. Select a repo. Next, click the  Git –> Utilities –> Get Script button from the menubar. A dialog shows up.

The Starting Commit ID is the Git Commit ID that is currently deployed in prod. Target Commit ID is the Git Commit ID that we would like to upgrade the prod database to.

Enter the Starting Git Commit ID and the Target Git Commit ID. Use the keyword HEAD if you’d like to use the latest commit in the current active branch as the Target Commit ID.

If you’d like the script to include soft objects (i.e. database objects that execute with CREATE OR REPLACE such as packages, views etc…) check the Include Soft Objects checkbox.

If you’d like the script to include hard objects (i.e. database objects that doesn’t execute with CREATE OR REPLACE such as tables) check the Include Hard Objects checkbox.

Click the Download DDL Script button. Gitora will generate a DDL script which, if executed, will syncronize a schema (or a group of schemas) which is currently at the Starting Commit ID, to the Target Commit ID.

As seen in this example, this feature can be used to apply the latest version of the source code to a production database. If the production database is at Git Commit Point A and the new production-ready version of the source code is at Git Commit Point B, a developer can enter A as the Starting Commit ID and B as the Target Commit ID and then execute the generated script in the production database.

Please note that the table generation is master-detail relationhip aware i.e. the generated tables will be in the correct order with master tables coming before detail tables that reference them.

Introduction to Gitora, Git for PL/SQL Developers

This document explains the core concepts in Gitora and how developers can use them to control the revisions they make to their Oracle database objects.

Gitora enables developers to perform regular version control tasks on the source code of their applications. Gitora supports every database schema object. It can perform Git commands on objects that can be created using the CREATE OR REPLACE command, namely; Packages, Views, Procedures, Functions, Triggers, Types and Synonyms. It can track every DDL performed on other database objects such as tables, indexes etc…

Behind the scenes, Gitora seamlessly integrates with Git, the prominent distributed version control system used by millions of developers worldwide. Gitora supports the following Git operations on the source code it manages:

  • Reset
  • Create Branch
  • Change Branch
  • Merge Branch
  • Fetch
  • Pull
  • Push

Gitora Web App

Gitora has both PL/SQL API’s and a web application to help developers manage their PL/SQL code using Git. Using Gitora Web App developers can:

  • Perform the supported version control functions using a point&click interface.
  • Check out database objects for editing
  • Browse the source code in the Git repository
  • Manage Git repositories.
  • Manage users

Creating A Version Control Repository

Open Gitora Web App and select Git->Repo->  New Repo from the menu bar. The Create a New Repo Dialog shows up.

Enter a name for your repository (A Gitora repository can contain PL/SQL objects from any database schema.) Click Save. Click OK in the Alert Box which shows the message received from Git. Note that the Gitora Web App makes the new repository you created the active one and the repository viewer focuses on it.

Adding Database Objects to a Gitora Repository

In order to be able to perform version control tasks with a database object, it must be added to a Gitora repository.

To add database objects to a Gitora repository, select Git-> “Add/Remove Objects” item from the menu bar.

Add/Remove Database Objects

The “Add or Remove Database Objects” Dialog shows up.

To add a database object to the Gitora repository, select the schema the object is in. Next, select the type of the object. Gitora supports the following object types: Table, Procedure, Function, Package, View, Trigger, Type, Synonym, Sequence and Materialized View.

Finally, select one or more objects from the list of available ones and add them to the list of managed objects. Add as many objects of different types as necessary.

A Note About Adding a Large Number of Objects

The Dialog supports adding tens even hundreds of objects at once, using the Add All button. However, this may take time because Gitora will extract the DDL of these objects and create files. If the number of objects you are adding to the repo at once is very high, the browser may prompt you that the application is unresponsive or the session in the Tomcat Server might expire (in about an hour).

If you are building a large Git repo, we recommend that you either add the objects in chunks or use the Gitora API’s.

Click “Done” to close the dialog.

A Gitora repository can manage database objects from multiple schemas. To add database objects from another schema simply change the schema name selected in the dialog’s select box and continue as described above.

Collaboration vs. Parallel Development

Unlike middle tier (Java, PHP etc…) or client side programming language code units (JavaScript, Objective-C etc..) PL/SQL code units do not reside in private files on a developer’s computer. They are globally available to every developer who has access to the database with the appropriate privileges. Therefore, PL/SQL developers mostly collaborate on the same PL/SQL code units (Packages, Procedures, Functions etc…) using a check-out mechanism to prevent themselves from overriding each other’s modifications.

When working together, developers of other programming languages have a different approach. They work on the same logical code unit but they always edit different physical copies of the same logical code unit. In most cases it is impractical for PL/SQL developers to set up their own private environments in which each developer has a private copy of the PL/SQL code units she is working on. Therefore, Gitora features a check-out mechanism to better fit into the regular workflow of PL/SQL developers. This enables a team of developers to collaborate on one branch of the application without stepping on each other’s toes.

More importantly however, Gitora also supports a workflow in which each developer works in her own environment and with her own database objects (similar to a middle tier or client developer). This way, developers can freely modify the same logical code units (but different physical copies) and merge their changes at a later point in time.

Editing a Database Object Managed by Gitora

Developers may continue using their favorite PL/SQL editor to edit database objects managed by Gitora. Since Gitora is implemented at the database level, it works with any editor.

Once a database object is in a Gitora repository, Gitora will only allow changes to it from database sessions which have a logged in Gitora user and if the database object is not already checked out by another Gitora user.

Use the following API’s in the API_GITORA package to sign in to Gitora with your Gitora user name and password.

login(in_user_cd varchar2, in_password_tx varchar2) :signs in to Gitora with a valid Gitora user name and password.

logout;signs out of Gitora

No Sign In Development

Gitora 5 can be configured to recognize Oracle Users as valid Gitora users. This eliminates the need to sign in to Gitora using the PL/SQL API above. We recommend this approach in environments where every developer has her own Oracle User.

To achieve this, log in to Gitora as an admin. Next, click the [Database Name]-> Users menu item from the menu bar. The Manage Users page shows up.

Click the Add button on the page. The Add User dialog shows up.

Enter the Oracle username to the User Name field (LISA in the screenshot). Check the Oracle User checkbox. The password fields will be disabled. The user will use her Oracle credentials to log in to Gitora. If you are using Gitora Enterprise, select a database role for the user, as well.

Click the Save button.

From this point on, the user (LISA in the example) can log in to the Gitora application with her Oracle username and password. She also doesn’t need to sign in to Gitora first to modify database objects managed by it because Gitora will recognize her as a valid user.

When a developer saves a PL/SQL object to the database, Gitora automatically attempts to check out the object if the database session has a logged in Gitora user.  If the object is already checked out by another developer, Gitora prevents the save with an appropriate error message.

Developers may also use the Gitora Web App to check out a database object from the navigation tree by right clicking it and selecting the check out menu item from the pop up menu.

Gitora Web App presents a green lock icon on database objects checked out by the logged in developer and a red lock icon on database objects checked out by other developers.

Committing Database Object Modifications

At any time the developer can view the list of objects she checked out from the “Git -> Commit” menu item.

Alternatively, she can use the “Commit ” icon in the toolbar to access the same dialog.

The “Commit Changes” page has two tabs. The “All Objects” tab shows the list of every database object in the current repository that is checked out by every developer. The “My Objects” tab shows only the objects the logged in developer checked out.

The developer can review changes made to each object by clicking the associated Diff link. She can also choose to include/exclude each object from the current commit by using the Include? checkbox.

The page has a section named “Managed Schema DDL’s”. We’ll talk about this section in a different blog post.

Gitora requires a developer to enter a short description of the changes she is commiting to the Commit Changes text area. This description comes in very handy when going over the history logs.

Clicking the Commit button commits the selected objects to the Git repo.

Once the Git commit is finished, Gitora displays the message it retrieves from the Git server. This message gives a summary of the updates made to the Git repository.

After the commit completes, objects included in the commit are automatically released and are no longer checked out by the developer.

Releasing an Object

If the developer wants to remove her edit lock on an object she checked out, she can do so by right clicking the object in the navigation tree and clicking the Release menu item. Please note that this will cancel all her changes to the object and the object will revert back to the latest state it is in on the active branch of the repo.

Resetting to a Commit ID

If a developer wants to cancel changes in an application’s current branch and bring it to a state it was at a certain point back in time, she can do so by using the Git->Reset menu item.

The “Reset” operation needs a valid Git Commit ID to function. The Git gives a unique ID to each commit issued by a developer. The developer can browse the Git repos  to determine the Commit ID she wants the application to revert back to.

To move back the application to a commit ID, click the “Git -> Reset” menu item.  The “Reset” dialog shows up. Paste the Commit ID value to the field named Commit ID and click the“Reset” button. The code base goes back to the state it was at that Commit ID and Gitora displays the message it received from the Git Server. The code in the database is also updated.

As a shortcut, you can revert to the previous state of the repository by entering HEAD@{1} as the Commit ID.

Please note that the reset command (just like every other command in Gitora) will only update the soft objects in the database. Soft objects are defined as objects that work with the CREATE OR REPLACE command. Therefore, it will not change any table, sequence or materialized view in the database.

Creating a Branch

Branching is a very powerful feature of version control systems that enables developers to work on multiple versions of a code base easily. For example, a developer can work on the master branch to fix bugs that are reported from the production environment and release maintenance versions while developing a new feature in the dev branch. The deployed new maintenance versions from the master branch never include the code written in the dev branch.

To create a new Branch click the “Git -> Create Branch” menu item. A dialog shows up.

Enter a name for the new branch. Enter the name of another branch, a tag name or a Commit ID as the starting point of the new branch. Keep the checkbox checked if you want to make this branch the active branch in the database.

Click the “Create Branch” button to create the new branch. Once it is created, the code base automatically switches over to the newly created branch if the Make Active Branch checkbox is checked.

Please note that there must not be any checked out objects in the repository for Gitora to be able to create a new branch.

Changing Branches

In order to change the current branch of the repository, open Gitora Web App, select a repo from the main select box and select the “Git -> Change Branch” menu item. A dialog shows up.

Select the branch to switch to and click the “Change Branch” button. The code base in the Oracle Database gets updated to show its state in the selected branch. Please note that there must not be any checked out objects in the code repository for Gitora to be able to switch to another branch.

Important Note: Git commands executed by Gitora only update soft objects. Soft objects are defined as database objects that work with the CREATE OR REPLACE command. Therefore Gitora does not change any tables, sequences and materialized views in the database.

Merging a Branch to another Branch

Creating and switching between branches would not be meaningful unless Gitora also enabled merging of a branch to another. For example, once the development on the dev branch is finished, developers should be able to move the changes to the master branch of the code base. This is called a merge.

To start a merge click the “Git -> Merge” menu item. A dialog shows up asking the source branch for the merge operation. The destination branch is always the current branch the code base is on.

Click the “Merge” button to start the merge operation.

During the merge operation, Gitora carries over the changes made in the source branch to the destination branch. In some cases Git may not be able to figure out the right operation to perform to bring over a particular change. These cases are called conflicts.

A conflict may occur if;

  • An object deleted in the source branch is modified in the destination branch.
  • An object is modified in the source branch and in the destination branch, and Git cannot consolidate these modifications. (For example, in both branches the same line of code in a PL/SQL procedure is modified. There is no way a version control system can figure out the right way to consolidate these two changes.)
  • An object modified in the source branch is deleted in the destination branch.
  • A newly created object in the source branch and a newly created object in the destination branch have the same name.

If there is a conflict in a database object after a merge, Gitora does the following in the destination schema:

  • It creates the database object in an uncompiled form with changes from both source and destination in it.
  • It creates the database object with “$M” (short for my object) suffix in its name which represents the content of the object in the destination branch  before the merge.
  • It creates the database object with “$T” (short for their object) suffix in its name which represents the object in the source branch.

The developer who started the merge is responsible to resolve the conflicts in the database objects that might occur after a merge operation.

Gitora provides an easy to use merge wizard to the developer so that she can keep track and mark the conflicts as resolved. The merge wizard shows a commit screen after all the conflicts are resolved. If there are no conflicts after a merge operation, the merge wizard does not show up.

Resolving Conflicts in Table, Sequence and Material View DDL’s.

Gitora 5 keeps track of table DDL’s just like it keeps track of soft objects. However, it does not update the database with the new definition of a table during a merge. Yet, a merge conflict might still occur in a table DDL if the table DDL was modified in two different branches.

In such a case, Gitora will show the table in the merge conflict screen. The table name will have a .sql suffix to indicate that the conflict is in a file managed by Git but the database is not affected. Gitora also provides an edit button for the user to edit the DDL text and resolve the conflict.

Until the merge conflicts are resolved, Gitora does not allow developers to modify the code base subject to the merge operation.

Please note that the developer is also responsible to fix the compilation errors that might occur after a merge operation which are different from the conflicts. There might be compilation errors after a merge even if there are no conflicts.