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 https://git-scm.com/. 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 fix_parameters_MAC.sh to edit.
    For Linux, open fix_parameters_LINUX.sh 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:@192.168.1.99:1521:orcl
  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, fix_parameters_MAC.sh for MAC OS, fix_parameters_LINUX.sh 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/startup.sh
  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.

Introducing Gitora 2.0

Today, we are happy to announce the general availability of Gitora 2.0. We listened to the feature requests coming from the community and we think we are addressing the majority of them with this new version.

Object Type Support

Gitora now supports Object Types. Object Types are supported for the Oracle version 11g and above.

Generate Diff Scripts

Gitora 2.0 helps you create diff scripts between two commit points in your Git repository. Simply, enter the starting Commit Point ID and the target Commit Point ID and Gitora will generate a diff script for you to run in your target database.

Clone Source Code from Another Database

Gitora 2.0 supports cloning Git repositories from remote databases. Connect your local Gitora to the remote Gitora (which manages a remote database) and move the code base from one database to the other automatically.

Pull(Merge), Fetch Source Code from Another Database

Similar to cloning, developers can now pull(merge) source code from a remote database to the source code in a local database automatically if both database are running Gitora 2.0.

Many small improvements and bug fixes

Gitora 2.0 also comes with a number of improvements such as:
– A nicer Git repository browser
– Ability to view changes made in each object prior to issuing a commit
– Cancel any edits made to a PL/SQL object since check-out by clicking a button.

New Gitora Editions

Gitora 2.0 comes in three editions:

Gitora Community Edition

Every feature from Gitora 1.0 continues to be free in Gitora 2.0 Community Edition. We even added new features to it such as object type support, ability to view changes made in each object and canceling edits, along with many bug fixes.

Gitora Professional Edition

We believe proper version control is a big problem in the PL/SQL community, hurting the productivity of many PL/SQL developers and discouraging organizations from using PL/SQL. We think we can help. In order to justify further development on Gitora to help the community to solve this problem, remote database features in Gitora 2.0 will be available in the professional addition. The professional edition also comes with email support and unlimited access to 2.X released of Gitora. We think the benefits you will get from Gitora Professional Edition will far outweigh the small price tag we put on it.

Gitora Enterprise Edition

We know that large enterprises usually have their own unique needs. They might need customizations, new features, integration with other products and services they use, training, more timely and intensive support covered with an SLA etc… For these types of customers, we offer a fully customizable version of Gitora.

Gitora 2.0 Professional Edition comes with a long trial period and even if you decide not to purchase it, it gracefully downgrades to the community edition.

So what are you waiting for? Go download Gitora 2.0! 🙂

Benefits of using Gitora, Git for PL/SQL Developers

Outside of the Database World (Java, JavaScript etc..) developers use version control systems more effectively. When used appropriately in the software development life cycle, a version control tool can shorten delivery times significantly by improving the manageability of the code base.

Using version control with PL/SQL (and other database objects) has always been challenging. In our experience very few, if any, IT departments use version control systems to manage their database. Most are content with a basic check-in check-out mechanism.

We created Gitora to help database developers manage their code base better. Gitora achieves this by bridging the gap between the Oracle Database and Git, the most prominent and popular version control system used by millions of developers around the world.

With Gitora you can:

  • Perform the version control operations using a point and click interface. This reduces the barrier to entry for Git. Only a basic understanding of version control principles is good enough to get value from the product.
  • Move your code base automatically to a specific version (for example to match it to the version in production.)
  • Create new branches to work on new features without affecting the master code base.
  • Change between different branches of your code base automatically.
  • Merge your branches to the master code base automatically.
  • Push your changes to remote repos in cloud services such as GitHub, GitLab and BitBucket.
  • Pull changes from other databases and merge these changes with your database code.
  • Browse the Git repository and see your commit history and changes associated with each commit.

Collaboration vs. Parallel Development

Gitora can be used in collaboration mode in which all database developers work in the same Oracle Schema(s). In this case Gitora supports a check-in check-out mechanism. This check in/out mechanism is tool independent. It works with SQL Developer, TOAD and PL/SQL Developer (or any other tool for that matter).

More importantly, Gitora can also be used in parallel development mode in which every database developer works in her own schema(s). In this way of working, (which is exactly how Java, .NET, JavaScript developers etc.. are working) each developer has her own copy of the database code and is free to make changes to them related to the task she has at hand. In parallel mode, no developer blocks the other because she is the only one who checks out the objects in her own schema(s). This improves development times significantly because more than one developer can work on the same logical object at the same time.

The software development team establishes a workflow to merge the changes of each developer and propagate these changes to the master code base. Gitora (via Git) also helps with this process with automated merging of changes. In the event of a conflict (where Git cannot figure out how to merge changes done by two developers to the same code unit) Gitora asks the user to resolve the conflict. Gitora creates multiple versions of the database code objects in question and helps the developers to resolve the issue. (Please see Introduction to Gitora, Git for PL/SQL developers for more information on this topic)

Best to our knowledge, Gitora is the only tool that is specifically designed to be used for parallel development with PL/SQL. We think parallel development is where a software team starts to get a lot of value from using a version control system. This helps establishing a formal workflow of incorporating changes to the master code base and to production.

Gitora integrates to your software development lifecycle. We cannot overstate how important this is. Gitora is not something you do on the side and it does not have back doors where you can circumvent version control. It becomes an essential part of your daily workflow. There are version control tools that people use on the side by copying and pasting scripts. This is a very error prone process because it requires developers to “remember” to do version control. Some version control tools only work within a specific tool (such as TOAD) and do not prevent the developer from opening another tool (such as PL/SQL developer) and modify code without using proper version control mechanisms.

For more information about Gitora, we recommend you to visit the following links:

Gitora Webinar Recording (and Slides)

Six Common Question About Gitora

What is the Difference between Gitora and SQL Developer’s Git Interface

Six Questions About Gitora

Recently. we received an email from a Gitora user with six questions. We think our answers might be interesting for others as well. So here they are:

1. Where is the remote repository created?
Gitora does not use a remote repository in its first version. Everything is handled using local repositories. You can still use a remote repository if you want. There is nothing in Gitora preventing you from doing that.

2. How do you lock database objects?
The users decide which database objects Gitora should manage. When a DDL is executed, a database level trigger created by Gitora ensures that the Oracle user running the DDL is signed in to Gitora and checked out the database object it is manipulating if it is an object managed by Gitora. If the object is checked out by another user already, the trigger throws an exception. There is a PL/SQL API for a database user to sign in to Gitora in her database session. Optionally, she can use the Gitora App to check out an object. Gitora is also quite pragmatic and automatically checks out the object if it is not currently checked out by anyone else.

3. Is there any relation between Gitora users and Database Users? If there isn’t any relation, how do I create Gitora users?
There is no relation between Gitora users and database users. You can use the Gitora App to create Gitora users. Then, to check out an object managed by Gitora, you can sign in to Gitora by either using its PL/SQL API or the Gitora App.

4. Do I have to log in to Gitora every time I create a new database session?
You have to log in to Gitora in a database session only if you want to modify a database object or check out a database object managed by Gitora. Signing in is a single line API call that probably can be automated by your PL/SQL development tool.

5. Where is the version history stored?
Everything related to versioning is done and stored in the Git repository. Gitora is only a bridge between the Oracle Database and the Git server.

6. How can we integrate Gitora to TOAD? Is there a plug-in?
There is no need for a plug-in. Gitora works with any PL/SQL development tool. It has a small set of PL/SQL API’s that you can call from any development tool. Gitora also has a web app you can use to perform common version control tasks.

What is the Difference between Gitora and SQL Developer’s Git Interface?

We’ve been getting this question a lot lately, so I thought it is a good idea to write a blog post about it.

In SQL Developer, you work in two ways:

  • You edit objects in the database and then you manually create files in a folder managed by Git.
  • You edit files managed by Git and execute them in the database.

SQL Developer helps you run Git commands on these files. When you issue a Git command that changes your code base, you have to manually carry over the changed code units to the database by running the scripts.

In Gitora, if you modify a PL/SQL code unit in the database, you do not need to manually copy the updated script to a folder managed by Git. Gitora does that automatically. Similarly, if you issue a Git command using Gitora’s point and click interface, Gitora automatically updates the PL/SQL code units  in tha database. Gitora also has a check out mechanism that works at the database level, meaning that if you check out a PL/SQL code unit, no one else can edit it until you release or commit it. This is enforced at the database level. So there are no back doors.

So the advantages of Gitora’s approach are:

– A lot less manual work. Every edit you make is synced to the file system by Gitora. Every Git command you execute, updates your database code automatically.

– A lot less human errors. Copying files back and forth manually is very error prone.

– Much easier team work. Gitora’s check out mechanism prevents others from making changes to objects you are working on.

– Well structured working directory. Gitora creates a well structured working directory with reasonable folder and file names for database objects. The locations of these files are also standard. When there is human decision involved with naming and putting files in the file system, a lot of errors can occur. Gitora prevents these errors.

– No back doors. Gitora enforces that if an object is being edited by someone, no one else can edit it. Version control is not something you do on the side but it is tightly integrated into your workflow and enforced.

– It works with any editor. You can use SQL Developer, SQL Navigaor, TOAD or PL/SQL Developer. It doesn’t matter. Everyone in your team can use a different editor if they choose to do so. Gitora still works.

Yalim K. Gerger

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.