Child pages
  • Updating a Local Database Using DBI Files

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Stoc

Overview

When using a local database instance for each developer, there is a need to make sure the database is up to date structurally. Most team providers will update the DBI files that store the database metadata, but these providers do not actually change the database. Changing the database is done in Servoy using Servoy's toolset. Servoy will modify the database, and also alert the developer if there is changes that require developer intervention.  Changes are considered at the table level and at the column level.

DBI Files

DBI Files are JSON files that contain meta data about the tables and columns in a database.

To view exactly what is in a DBI file:

  1. Open the Resource perspective.
  2. Expand the Resource project and right-click the orders.dbi desired file. From the contextual popup, select Open With > Text Editor and view the resource as a JSON file.

  1. Return to the Servoy Design perspective and Right-click the Resources node and from the contextual popup menu, select Team > Commit... Add a comment and click OK.

Image Removed

...

Syncing DBI Files with the Local Database

There are a couple of Servoy Developer features used for changing the local database.

Synchronize With Database Wizard

The synchronize with database wizard will allow creation and deletion of tables in database based on DBI file information. It will also create columns associated with these tables.
 
To launch the wizard:

  1. In the Solution Explorer, right click on one of the following:
    1. The resources project
    2. The database servers node under the resources project
    3. The desired database under the database servers node
  2. Select Synchronize with DB server information.
  3. A wizard will appear. Walk through the wizard to update the databases
    Image Added

Problems Tab Quick Fix

Unfortunately, the wizard will not fix any differences with existing tables in the database. Any differences between the DBI files and the local database will show up in the Problems tab, and these differences can be fixed using the Quick Fix menu option.
To use the Problems tab:

...

  1. Find the error in the Problems tab indicating that the DBI file is out of sync with the database. Right-click the error and from the contextual popup, select Quick Fix
    Image Modified
  1. Image Removed In the Quick Fix dialog, you'll have two options. Select the option to create the column in the database table and click OK. The column will be added to the database

Image Removed

  1. Create a new table on example_data database called new_table, add a few arbitrary columns and save. Again, you should see the asterisk indication on the Resources node in the Project Explorer for outgoing changes. Commit the change to the repository.
  2. Again, you will use the dual workspace to emulate another developer and separate database. Delete the table you just created and switch workspaces back to the developer_2 workspace.
  3. Right-click the Resources node in the Solution Explorer and from the contextual popup menu, select Team > Update. This will create the new DBI file in the workspace.
  4. You should see a warning in the Problems tab indicating that the DBI file and the database are not in sync. Right-click the warning and from the contextual popup, select Quick Fix. The indication in the Quick Fix Dialog is to launch the Database Synchronization Wizard.

Image Removed

  1. Another way to launch the wizard is from the Project Explorer. Right-Click the Database Servers node and from the contextual popup, select Synchronize with DB Server information.

Image Removed

  1. Select the Create Table option and click finish. The table is now created in the local database copy.
  1. The quick fix dialog will appear. There are normally two options: to change the DBI file or to change the local database. Depending on which is correct, make the appropriate selection and click Finish.
    Image Added
  2. Note that if there are similar errors, you may choose to do the same action across all error of the same type. This will be the default behavior, but if you want just one or a few, you may clear the checkboxes in the problems list before clicking Finish.
  3. In the problems list, if there are new tables that have not been synced yet, you may see a warning indicated the table does not exist in the database. You may use Quick Fix to open the synchronize with database wizard as well.
    Image Added

Some Notes about Team Development and Database Synchronization

  • Database column changes will sometimes remove the data from the column (this is dependent on the platform and the type of change). This cannot be undone without a restore of the database from back up. Normally in development, there is little data in a database, but be careful.
  • Do not simply walk through the synchronization and quick fix wizards. You must think about the choices you make when making selections. For the most part, the reason differences appear is because another developer has changed the database for some reason. It very easy to get into a 'loop' because one developer has added a database object and another one has destroyed it and changed the DBI file, then committed the change. Communication between developers is key when making database changes in the solution.