createTable extension
🌐 This document is available in both English and Ukrainian. Use the language toggle in the top right corner to switch between versions. |
1. Overview
The createTable
tag, which is required for creating tables in a database, is standard for Liquibase. However, in liquibase-ddm-ext, additional parameters specific to the Platform are handled.
2. Liquibase schema
It is stored in the same schema as other standard Liquibase tags, according to the official documentation (currently using version 4.15).
Attributes specific to liquibase-ddm-ext:
<xsd:attribute name="historyFlag" type="xsd:boolean"/>
<xsd:attribute name="readMode" type="readType" default="sync"/>
<xsd:attribute name="distribution" type="distributionType" default="local"/>
<xsd:attribute name="classify" type="classifyType"/>
<xsd:attribute name="autoGenerate" type="xsd:string"/>
<xsd:attribute name="bulkLoad" type="xsd:boolean"/>
3. Example usage
<changeSet id="table pd_processing_consent" author="registry owner">
<comment>CREATE TABLE pd_processing_consent</comment>
<ext:createTable tableName="pd_processing_consent" ext:historyFlag="true" ext:bulkLoad="true">
<column name="consent_id" type="UUID">
<constraints nullable="false" primaryKey="true" primaryKeyName="pk_pd_processing_consent"/>
</column>
<column name="consent_date" type="TIMESTAMPTZ">
<constraints nullable="false"/>
</column>
<column name="person_gender" type="type_gender">
<constraints nullable="false"/>
</column>
<column name="person_full_name" type="TEXT">
<constraints nullable="false"/>
</column>
<column name="person_pass_number" type="TEXT">
<constraints nullable="false"/>
</column>
<column name="auto_generated_number" type="TEXT" ext:autoGenerate="AA-{DDMMYYYY}-{SEQ}">
<constraints nullable="false" unique="true"/>
</column>
</ext:createTable>
</changeSet>
4. Parameter description
- Parameters for the main
ext:createTable
tag -
Parameter name
Possible values
description
historyFlag
true
Creates a corresponding history table for the specified table with the suffix
_hst
, where all record changes are stored.bulkLoad
true/false
Modifies the generated service API to determine if a transaction-safe endpoint will be generated, allowing multiple entities to be saved in a single request.
isObject
true/false
Defines the table as an object (adds a link to the subject table).
You can find more details about parameter usage on the following pages:
- Parameters for nested
column
tags -
Attribute Name (name)
Possible Values (value)
Description
classify
private
/confidential
Classifies the data in the column as personal.
autoGenerate
Pattern for generating values in the column (e.g., AA-{dd-MM-yyyy}-{SEQ})
Generates unique values in the column according to the specified pattern.
You can find more details about parameter usage on the following pages:
5. Generated database queries
The following queries are generated for the table in the example:
CREATE TABLE registry.pd_processing_consent_hst (consent_id UUID NOT NULL, consent_date TIMESTAMP WITH TIME ZONE NOT NULL, person_gender TYPE_GENDER NOT NULL, person_full_name TEXT NOT NULL, person_pass_number TEXT NOT NULL, auto_generated_number TEXT NOT NULL, ddm_created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL, ddm_created_by TEXT NOT NULL, ddm_dml_op CHAR(1) NOT NULL, ddm_system_id UUID NOT NULL, ddm_application_id UUID NOT NULL, ddm_business_process_id UUID, ddm_business_process_definition_id TEXT, ddm_business_process_instance_id TEXT, ddm_business_activity TEXT, ddm_business_activity_instance_id TEXT, ddm_digital_sign TEXT, ddm_digital_sign_derived TEXT, ddm_digital_sign_checksum TEXT, ddm_digital_sign_derived_checksum TEXT, CONSTRAINT pk_pd_processing_consent PRIMARY KEY (consent_id), CONSTRAINT ui_pd_processing_consent_hst UNIQUE (consent_id, ddm_created_at));
ALTER TABLE registry.pd_processing_consent_hst DROP CONSTRAINT pk_pd_processing_consent;
REVOKE ALL PRIVILEGES ON TABLE pd_processing_consent_hst FROM PUBLIC;
GRANT SELECT ON pd_processing_consent_hst TO application_role;
CREATE TABLE registry.pd_processing_consent (consent_id UUID NOT NULL, consent_date TIMESTAMP WITH TIME ZONE NOT NULL, person_gender TYPE_GENDER NOT NULL, person_full_name TEXT NOT NULL, person_pass_number TEXT NOT NULL, auto_generated_number TEXT NOT NULL, ddm_created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL, ddm_created_by TEXT NOT NULL, ddm_updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL, ddm_updated_by TEXT NOT NULL, CONSTRAINT pk_pd_processing_consent PRIMARY KEY (consent_id), UNIQUE (auto_generated_number));
REVOKE ALL PRIVILEGES ON TABLE pd_processing_consent FROM PUBLIC;
GRANT SELECT ON pd_processing_consent TO application_role;
CREATE SEQUENCE IF NOT EXISTS pd_processing_consent_auto_generated_number_seq INCREMENT BY 1 OWNED BY pd_processing_consent.auto_generated_number;
GRANT USAGE ON SEQUENCE pd_processing_consent_auto_generated_number_seq TO application_role;
insert into ddm_liquibase_metadata(change_type, change_name, attribute_name, attribute_value) values ('autoGenerate', 'pd_processing_consent', 'auto_generated_number', 'AA-{DDMMYYYY}-{SEQ}');
insert into ddm_liquibase_metadata(change_type, change_name, attribute_name, attribute_value) values ('bulkLoad', 'pd_processing_consent', 'bulkLoad', 'true');
INSERT INTO public.ddm_db_changelog (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('table pd_processing_consent', 'registry owner', 'main-liquibase.xml', NOW(), 55, '8:1d833a79f2d827609a61ac1df5354bd4', 'createTable tableName=pd_processing_consent', 'CREATE TABLE pd_processing_consent', 'EXECUTED', NULL, NULL, '4.5.0', '7604867906');