The object ids swapping tool is mostly used to solve some conflicts that the validation tool can't. It basically grants the user full control over the creation order of the objects in the database model. You seldom need to use this feature but there are very few cases in which its use is needed.
One example could be a function that inside its source code references a table somehow but the table is being created after the function. Since the validation tool lacks the ability to check conflicts inside the object's SQL code, in the presented scenario, the model would validate without problems except when running the SQL code validation (fourth and optional step). In this case, PostgreSQL would detect the reference breaking due to the malformed code. In order to solve problems like this, the user can manually swap the creation order of the objects using the dialog below. In that form, one can specify which object will be created before another so any reference breaking not detected by the validation can be solved.
Another example of usage of this tool is when the default value of a column uses a function call like nextval(some_sequence::regclass)
and that sequence is being created after the table that owns the column. The solution here is to swap the ids of the sequence and table making the first object to be created before the latter. It's important to warn that changes made in this dialog are irreversible and cause the operation history to be erased and to put the model in a modified state which demands validation.
The objects swapping dialog allows the user to move objects freely to the desired position in the creation order. To do so just select an item in the list of objects and hit Ctrl + Up
or Ctrl + Down
to move it up or down respectively. Doing this will cause the object right above or below to swap positions with the selected one. Remember that any modification on this dialog needs to be validated prior to saving the model or exporting it to a database server. The fields of the form are described below.
Action/Field | Description |
---|---|
Create |
This object picker defines the object to be created before another one. |
Before |
This object picker defines the object which will be placed after the one selected in the above picker. |
Swap values |
The button with the icon swaps the object pickers' values. |
Swap ids |
This button applies the ID swapping. |
Filter |
This button toggles the filtering operation over the objects grid by matching the object names with user-provided keywords. |
Hide system objects |
This option causes system objects to be hidden since they can't be swapped with any other object in the model. |
Hide relationships |
This option causes relationships to be hidden since they can't be swapped with any other objects in the model except for other relationships. |
Object listing |
The object listing shows the creation order of all objects in the database model and is used as an alternative way the select the objects to be swapped. Objects can be selected by double-clicking any item on the grid. The first double-click will place the object in the Create picker and a second double-click will set the Before picker with the object selected on the listing. |