Top Constructors Methods
liquibase.snapshot.jvm

public Class UniqueConstraintSnapshotGenerator

extends JdbcSnapshotGenerator
Class Inheritance
Known Direct Subclasses
liquibase.snapshot.jvm.UniqueConstraintSnapshotGeneratorSnowflake
Imports
java.sql.SQLException, java.util.ArrayList, .HashMap, .HashSet, .List, .Map, .Set, java.util.concurrent.ConcurrentHashMap, java.util.stream.Collectors, liquibase.Scope, liquibase.database.Database, liquibase.database.core.*, liquibase.exception.DatabaseException, .UnexpectedLiquibaseException, liquibase.executor.ExecutorService, liquibase.snapshot.CachedRow, .DatabaseSnapshot, .JdbcDatabaseSnapshot, liquibase.statement.SqlStatement, liquibase.statement.core.RawParameterizedSqlStatement, .RawSqlStatement, liquibase.structure.DatabaseObject, liquibase.structure.core.Catalog, .Column, .Index, .Relation, .Schema, .Table, .UniqueConstraint, liquibase.util.StringUtil

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
protected String
getCacheKey(UniqueConstraint example, Database database)

Return the cache key for the given UniqueConstraint.

protected String
getCacheKey(Map<String, ?> row, Database database)

Return the cache key for the given query row.

public int
getPriority(Class<? extends DatabaseObject>
The object type we are asked to snapshot
objectType
,
Database
The DBMS for which the snapshotting should be done
database
)

Overrides liquibase.snapshot.jvm.JdbcSnapshotGenerator.getPriority.

Implements liquibase.snapshot.SnapshotGenerator.getPriority.

Inquire if this SnapshotGenerator is capable of snapshotting objects of type objectType (e.g. Table, Index, View etc.) in the DBMS database (e.g. Oracle, Postgres, HyperSQL etc.) A return priority of > 0 will be interpreted as capable.

private String

Returns:

A lengthy SQL statement that fetches the constraint names and columns
getUniqueConstraintsSqlInformix
(InformixDatabase
A database object of the InformixDatabase type
database
,
Schema
Name of the schema to examine (or null for all)
schema
,
String
Name of the constraint to examine (or null for all)
name
)

Gets an SQL query that returns the constraint names and columns for all UNIQUE constraints.

protected boolean
includeTableNameInCacheKey(Database database)

Should the given database include the table name in the key?

protected List<Map<String, ?>>
protected List<CachedRow>
listConstraints(Table table, DatabaseSnapshot snapshot, Schema schema)

private void
setValidateOptionIfAvailable(Database
- DB where UC will be created
database
,
UniqueConstraint
- UC object to persist validate option
uniqueConstraint
,
Map<String, ?>
- it's a cache-map to get metadata about UC
columnsMetadata
)

Method to map 'validate' option for UC.

protected DatabaseObject
protected boolean
supportsBulkQuery(Database database)

To support bulk query, the resultSet must include a CONSTRAINT_CONTAINER column for caching purposes

Inherited from liquibase.snapshot.jvm.JdbcSnapshotGenerator:
addStatusListeneraddsTocleanNameFromDatabasegetDatabaseCatalogNamesreplacesshouldAddTosnapshotupdateListeners

Constructor Detail

UniqueConstraintSnapshotGeneratorback to summary
public UniqueConstraintSnapshotGenerator()

Method Detail

addToback to summary
protected void addTo(DatabaseObject foundObject, DatabaseSnapshot snapshot) throws DatabaseException

Implements abstract liquibase.snapshot.jvm.JdbcSnapshotGenerator.addTo.

Annotations
@Override
getCacheKeyback to summary
protected String getCacheKey(UniqueConstraint example, Database database)

Return the cache key for the given UniqueConstraint. Must return the same result as getCacheKey(Map, Database). Default implementation uses includeTableNameInCacheKey(Database) to determine if the table name should be included in the key or not.

getCacheKeyback to summary
protected String getCacheKey(Map<String, ?> row, Database database)

Return the cache key for the given query row. Must return the same result as getCacheKey(UniqueConstraint, Database) Default implementation uses includeTableNameInCacheKey(Database) to determine if the table name should be included in the key or not.

getPriorityback to summary
public int getPriority(Class<? extends DatabaseObject> objectType, Database database)

Overrides liquibase.snapshot.jvm.JdbcSnapshotGenerator.getPriority.

Implements liquibase.snapshot.SnapshotGenerator.getPriority.

Doc from liquibase.snapshot.SnapshotGenerator.getPriority.

Inquire if this SnapshotGenerator is capable of snapshotting objects of type objectType (e.g. Table, Index, View etc.) in the DBMS database (e.g. Oracle, Postgres, HyperSQL etc.) A return priority of > 0 will be interpreted as capable. The highest priority for an objectType-database combination wins.

Parameters
objectType:Class<? extends DatabaseObject>

The object type we are asked to snapshot

database:Database

The DBMS for which the snapshotting should be done

Returns:int

An integer of PRIORITY_... constants indicating our capability and willingness to snapshot

Annotations
@Override
getUniqueConstraintsSqlInformixback to summary
private String getUniqueConstraintsSqlInformix(InformixDatabase database, Schema schema, String name)

Gets an SQL query that returns the constraint names and columns for all UNIQUE constraints.

Parameters
database:InformixDatabase

A database object of the InformixDatabase type

schema:Schema

Name of the schema to examine (or null for all)

name:String

Name of the constraint to examine (or null for all)

Returns:String

A lengthy SQL statement that fetches the constraint names and columns

includeTableNameInCacheKeyback to summary
protected boolean includeTableNameInCacheKey(Database database)

Should the given database include the table name in the key? Databases that need to include the table names are ones where unique constraint names do not have to be unique within the schema.

Currently only mysql is known to have non-unique constraint names.

If this returns true, the database-specific query in listColumns(UniqueConstraint, Database, DatabaseSnapshot) must include a TABLE_NAME column in the results for getCacheKey(Map, Database) to use.

listColumnsback to summary
protected List<Map<String, ?>> listColumns(UniqueConstraint example, Database database, DatabaseSnapshot snapshot) throws DatabaseException
listConstraintsback to summary
protected List<CachedRow> listConstraints(Table table, DatabaseSnapshot snapshot, Schema schema) throws DatabaseException, SQLException
setValidateOptionIfAvailableback to summary
private void setValidateOptionIfAvailable(Database database, UniqueConstraint uniqueConstraint, Map<String, ?> columnsMetadata)

Method to map 'validate' option for UC. This thing works only for ORACLE

Parameters
database:Database

- DB where UC will be created

uniqueConstraint:UniqueConstraint

- UC object to persist validate option

columnsMetadata:Map<String, ?>

- it's a cache-map to get metadata about UC

snapshotObjectback to summary
protected DatabaseObject snapshotObject(DatabaseObject example, DatabaseSnapshot snapshot) throws DatabaseException

Implements abstract liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshotObject.

Annotations
@Override
supportsBulkQueryback to summary
protected boolean supportsBulkQuery(Database database)

To support bulk query, the resultSet must include a CONSTRAINT_CONTAINER column for caching purposes