Fixed-Name Directories in the SCM Repository
Use the following structure and naming. You can create sub-directories as desired.
<sql_code_dir> # for example, sql_scripts archive data_dml ddl function package packagebody procedure sql_direct ssis ssis_project trigger view
Script Directories
SCM Directory Name | Description |
---|---|
<sql_code_dir> | User-defined directory in SCM to use as the root for SQL scripts. Subdirectories are provided for different types of SQL. Example: |
archive | The archive directory is created and managed by the Deployment Packager. Files added in the ddl, sql, sqlplus, sql_direct, and data_dml directories will be copied here after successful Packaging to prevent post Packaging modification. The user does not need to create this directory. |
data_dml | Contains scripts that load, manipulate or delete data. |
ddl | Contains scripts that make ddl changes such as creating, modifying, and dropping tables, indexes, sequences, and other database objects that are not one of the other types. |
function | Contains scripts that create or replace one function. |
package | Contains scripts that create or replace one package definition. |
packagebody | Contains scripts that create new or replace existing package bodies. |
procedure | Contains scripts that create or replace one procedure. |
sql | Limited Use. Creates a It's strongly suggested to use |
sqlplus | Deprecated. Use |
sql_direct | The scripts are run directly using the database's native client. The changesets are database-specific. They cannot be deployed to other database platforms.
|
ssis | Contains .dtsx files (SSIS Package) and other support files used in ETL processes. |
ssis_project | Contains .ispac files (SSIS Project) |
trigger | Contains SQL scripts that create or replace one trigger. |
view | Contains SQL scripts that create or replace one view. |
Additional Guidelines for Objects
Object Type | Notes |
---|---|
Databases and Schema | Create databases, schema, tablespaces, users and roles outside of Datical. Datical is typically used to manage objects and data once the environment has been setup. |
Inserts, Updates and Deletes (DML) | Place DML scripts into the |
Procedures, Packages, Functions, Views and Triggers (Stored Logic) | Objects are managed as non-transient changes. Scripts remain in their folders after packaging. They are not moved to the archive directory. This behavior supports managing database changes like application source code: the same code is updated in place as changes are needed. By contrast, once DDL changes are made, the script is moved to the archive directory. When the changes are committed, Datical repackages the file and increments the version (the versioning feature was available as of Datical DB 4.31). For stored logic scripts, create objects using the CREATE command. When you update and deploy the file again, Datical automatically converts the CREATE to an ALTER as needed. Permissions are maintained on the object when deployed. Note Stored-logic scripts must create only one object per script. |
Complex and Interdependent Database Changes | Normally DDL changes are placed in the / However, when you need to package complex and interdependent changes, place them in the If the order that the multiple statements are listed in the single script is critical to the success of the script, then put it in the Examples of sets of statements in a single sql script that need to be placed into create table move data from old table to new table drop old table alter table drop pk constraint alter table drop column (a column that the pk constraint depends on) alter table add column (a column that the pk constraint depends on) alter table add pk constraint |
Rename any object | Place SQL scripts into the /sql or /sql_direct folder. When you do, they are processed as a rename operation (rather than a DROP and CREATE). |
Using Changelog Properties | All sql scripts can take advantage of properties. Property key/value pairs are set directly in the changelog. See /wiki/spaces/DDOC59/pages/795771617. |
SQL Types and Changeset Processing
Description | SQL Statements | Process Type for Packaging |
---|---|---|
DDL - Data Definition Language | CREATE, ALTER, DROP, COMMENT | Transient |
DML - Data Manipulation Language | INSERT, UPDATE, DELETE, TRUNCATE, MERGE, SELECT | Transient |
DCL - Data Control Language | GRANT, REVOKE | Transient |
Stored Logic | CREATE (OR REPLACE) / DROP PACKAGE, PACKAGE BODY, PROCEDURE, FUNCTION, TRIGGER | Non-transient |
Processing Changes
The process type drives the type of processing used, the type changeset produced and determines if the original scripts are archived.
Transient versus Non-transient processing
Process Type | Processing | Directories |
---|---|---|
Transient |
| ddl sql_direct data_dml |
Non-transient |
| all other directories |
Different Packaging Folders/Methods processing
Process Type | Processing | Directories |
---|---|---|
Convert SQL |
| ddl folder (CONVERT packaging method) |
Native SQL |
| data_dml and sql_direct folders (DATA_DML and DIRECT packaging methods) |
Stored Logic |
| function, package, packagebody, procedure, trigger, and view folders (STOREDLOGIC packaging method) |
SQLFILE |
| sql folder (SQLFILE packaging method) |
Please see Overview of Packaging for more information about packaging workflows and Convert SQL method (ddl folder) versus Native SQL methods.
Processing Order
Deployment Packager in SCM Mode follows 3 ordering tiers for automating the execution order of new SQL scripts:
- Tier 1: Commit Sequence
- The group of files in a single commit is processed as a unit. Within a commit, files are processed within the file type sequence and then within the filename sequence.
- Groups of commits are processed in order of checkin time. The earliest commit is processed first, then the next, and so on.
- If you commit a file as part of a group and then later commit it again with changes (with a group), it is processed with the later commit group.
- Tier 2: File Type Sequence
- ddl
- view
- ssis/ssis_project
- function
- procedure
- package
- packagebody
- trigger
- sql
- sqlplus
- sql_direct
- data_dml
- Tier 3: Filename Sequence
If multiple files are included in the same commit, and in the same directory, then files will be executed in alphabetical filename order
NOTE: You may need to perform separate commits in cases where objects are created and accessed in different steps in the execution order. For example, you may want to commit views for tables that are not created until the sql_direct step. In that case, commit the view separately after you have committed the steps that create the tables.
If this default processing order is different than your goals, you might consider using a Custom Packaging Order instead.
Source Control Operations and Packaging Effects
SCM Operation | Effect on Packaging |
---|---|
Check In New File | Processed as a new file. The changes are packaged as a changeset to be added to the changelog.xml file. |
Rename File | Packaging processes the script with the new filename as a new changeset. |
Move File | Moving a file more than once may cause errors. |
Delete File | Deleting a file has no effect on the changelog.xml file. |
Defining Labels in SCM Check In Comments
The packager parses the source control commit message. Strings enclosed by square brackets are treated as labels for the changeset generated by packaging sql scripts.
For example, if a developer checked in a SQL script with the following comment:
Add a new column foo to the table bar [label1,label2] [label3]
The packager adds labels to all changesets generated from the SQL script:
label1 label2 label3
See also these pages for an overview of packager workflows, guidelines for writing scripts, and when to use which folder or packaging method:
Writing SQL Scripts for Datical DB
Oracle Database Objects and Packaging
SQL Server Database Objects and Packaging
How To: Choose Between CONVERT (ddl) and DIRECT (sql_direct) Packaging Methods
What is the difference between "ddl" and "sql_direct" folders?