Java Code Examples for liquibase.database.Database#setLiquibaseSchemaName()
The following examples show how to use
liquibase.database.Database#setLiquibaseSchemaName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DbSchemaDrop.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public static void main(String[] args) { try { FormEngine formEngine = FormEngines.getDefaultFormEngine(); DataSource dataSource = formEngine.getFormEngineConfiguration().getDataSource(); DatabaseConnection connection = new JdbcConnection(dataSource.getConnection()); Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection); database.setDatabaseChangeLogTableName(FormEngineConfiguration.LIQUIBASE_CHANGELOG_PREFIX+database.getDatabaseChangeLogTableName()); database.setDatabaseChangeLogLockTableName(FormEngineConfiguration.LIQUIBASE_CHANGELOG_PREFIX+database.getDatabaseChangeLogLockTableName()); if (StringUtils.isNotEmpty(formEngine.getFormEngineConfiguration().getDatabaseSchema())) { database.setDefaultSchemaName(formEngine.getFormEngineConfiguration().getDatabaseSchema()); database.setLiquibaseSchemaName(formEngine.getFormEngineConfiguration().getDatabaseSchema()); } if (StringUtils.isNotEmpty(formEngine.getFormEngineConfiguration().getDatabaseCatalog())) { database.setDefaultCatalogName(formEngine.getFormEngineConfiguration().getDatabaseCatalog()); database.setLiquibaseCatalogName(formEngine.getFormEngineConfiguration().getDatabaseCatalog()); } Liquibase liquibase = new Liquibase("org/activiti/form/db/liquibase/activiti-form-db-changelog.xml", new ClassLoaderResourceAccessor(), database); liquibase.dropAll(); } catch (Exception e) { e.printStackTrace(); } }
Example 2
Source File: FormEngineConfiguration.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void initDbSchema() { try { DatabaseConnection connection = new JdbcConnection(dataSource.getConnection()); Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection); database.setDatabaseChangeLogTableName(LIQUIBASE_CHANGELOG_PREFIX+database.getDatabaseChangeLogTableName()); database.setDatabaseChangeLogLockTableName(LIQUIBASE_CHANGELOG_PREFIX+database.getDatabaseChangeLogLockTableName()); if (StringUtils.isNotEmpty(databaseSchema)) { database.setDefaultSchemaName(databaseSchema); database.setLiquibaseSchemaName(databaseSchema); } if (StringUtils.isNotEmpty(databaseCatalog)) { database.setDefaultCatalogName(databaseCatalog); database.setLiquibaseCatalogName(databaseCatalog); } Liquibase liquibase = new Liquibase("org/activiti/form/db/liquibase/activiti-form-db-changelog.xml", new ClassLoaderResourceAccessor(), database); if (DB_SCHEMA_UPDATE_DROP_CREATE.equals(databaseSchemaUpdate)) { logger.debug("Dropping and creating schema FORM"); liquibase.dropAll(); liquibase.update("form"); } else if (DB_SCHEMA_UPDATE_TRUE.equals(databaseSchemaUpdate)) { logger.debug("Updating schema FORM"); liquibase.update("form"); } else if (DB_SCHEMA_UPDATE_FALSE.equals(databaseSchemaUpdate)) { logger.debug("Validating schema FORM"); liquibase.validate(); } } catch (Exception e) { throw new ActivitiFormException("Error initialising form data schema", e); } }
Example 3
Source File: DmnEngineConfiguration.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void initDbSchema() { try { DatabaseConnection connection = new JdbcConnection(dataSource.getConnection()); Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection); database.setDatabaseChangeLogTableName(LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogTableName()); database.setDatabaseChangeLogLockTableName(LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogLockTableName()); if (StringUtils.isNotEmpty(databaseSchema)) { database.setDefaultSchemaName(databaseSchema); database.setLiquibaseSchemaName(databaseSchema); } if (StringUtils.isNotEmpty(databaseCatalog)) { database.setDefaultCatalogName(databaseCatalog); database.setLiquibaseCatalogName(databaseCatalog); } Liquibase liquibase = new Liquibase("org/activiti/dmn/db/liquibase/activiti-dmn-db-changelog.xml", new ClassLoaderResourceAccessor(), database); if (DB_SCHEMA_UPDATE_DROP_CREATE.equals(databaseSchemaUpdate)) { logger.debug("Dropping and creating schema DMN"); liquibase.dropAll(); liquibase.update("dmn"); } else if (DB_SCHEMA_UPDATE_TRUE.equals(databaseSchemaUpdate)) { logger.debug("Updating schema DMN"); liquibase.update("dmn"); } else if (DB_SCHEMA_UPDATE_FALSE.equals(databaseSchemaUpdate)) { logger.debug("Validating schema DMN"); liquibase.validate(); } } catch (Exception e) { throw new ActivitiDmnException("Error initialising dmn data model"); } }
Example 4
Source File: DbSchemaDrop.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public static void main(String[] args) { try { DmnEngine dmnEngine = DmnEngines.getDefaultDmnEngine(); DataSource dataSource = dmnEngine.getDmnEngineConfiguration().getDataSource(); DatabaseConnection connection = new JdbcConnection(dataSource.getConnection()); Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection); database.setDatabaseChangeLogTableName(DmnEngineConfiguration.LIQUIBASE_CHANGELOG_PREFIX+database.getDatabaseChangeLogTableName()); database.setDatabaseChangeLogLockTableName(DmnEngineConfiguration.LIQUIBASE_CHANGELOG_PREFIX+database.getDatabaseChangeLogLockTableName()); if (StringUtils.isNotEmpty(dmnEngine.getDmnEngineConfiguration().getDatabaseSchema())) { database.setDefaultSchemaName(dmnEngine.getDmnEngineConfiguration().getDatabaseSchema()); database.setLiquibaseSchemaName(dmnEngine.getDmnEngineConfiguration().getDatabaseSchema()); } if (StringUtils.isNotEmpty(dmnEngine.getDmnEngineConfiguration().getDatabaseCatalog())) { database.setDefaultCatalogName(dmnEngine.getDmnEngineConfiguration().getDatabaseCatalog()); database.setLiquibaseCatalogName(dmnEngine.getDmnEngineConfiguration().getDatabaseCatalog()); } Liquibase liquibase = new Liquibase("org/activiti/dmn/db/liquibase/activiti-dmn-db-changelog.xml", new ClassLoaderResourceAccessor(), database); liquibase.dropAll(); } catch (Exception e) { e.printStackTrace(); } }
Example 5
Source File: DbSchemaDrop.java From flowable-engine with Apache License 2.0 | 5 votes |
public static void main(String[] args) { try { DmnEngine dmnEngine = DmnEngines.getDefaultDmnEngine(); DataSource dataSource = dmnEngine.getDmnEngineConfiguration().getDataSource(); DatabaseConnection connection = new JdbcConnection(dataSource.getConnection()); Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection); database.setDatabaseChangeLogTableName(DmnEngineConfiguration.LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogTableName()); database.setDatabaseChangeLogLockTableName(DmnEngineConfiguration.LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogLockTableName()); if (StringUtils.isNotEmpty(dmnEngine.getDmnEngineConfiguration().getDatabaseSchema())) { database.setDefaultSchemaName(dmnEngine.getDmnEngineConfiguration().getDatabaseSchema()); database.setLiquibaseSchemaName(dmnEngine.getDmnEngineConfiguration().getDatabaseSchema()); } if (StringUtils.isNotEmpty(dmnEngine.getDmnEngineConfiguration().getDatabaseCatalog())) { database.setDefaultCatalogName(dmnEngine.getDmnEngineConfiguration().getDatabaseCatalog()); database.setLiquibaseCatalogName(dmnEngine.getDmnEngineConfiguration().getDatabaseCatalog()); } Liquibase liquibase = new Liquibase("org/flowable/dmn/db/liquibase/flowable-dmn-db-changelog.xml", new ClassLoaderResourceAccessor(), database); liquibase.dropAll(); liquibase.getDatabase().close(); } catch (Exception e) { e.printStackTrace(); } }
Example 6
Source File: DbSchemaDrop.java From flowable-engine with Apache License 2.0 | 5 votes |
public static void main(String[] args) { try { FormEngine formEngine = FormEngines.getDefaultFormEngine(); DataSource dataSource = formEngine.getFormEngineConfiguration().getDataSource(); DatabaseConnection connection = new JdbcConnection(dataSource.getConnection()); Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection); database.setDatabaseChangeLogTableName(FormEngineConfiguration.LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogTableName()); database.setDatabaseChangeLogLockTableName(FormEngineConfiguration.LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogLockTableName()); if (StringUtils.isNotEmpty(formEngine.getFormEngineConfiguration().getDatabaseSchema())) { database.setDefaultSchemaName(formEngine.getFormEngineConfiguration().getDatabaseSchema()); database.setLiquibaseSchemaName(formEngine.getFormEngineConfiguration().getDatabaseSchema()); } if (StringUtils.isNotEmpty(formEngine.getFormEngineConfiguration().getDatabaseCatalog())) { database.setDefaultCatalogName(formEngine.getFormEngineConfiguration().getDatabaseCatalog()); database.setLiquibaseCatalogName(formEngine.getFormEngineConfiguration().getDatabaseCatalog()); } Liquibase liquibase = new Liquibase("org/flowable/form/db/liquibase/flowable-form-db-changelog.xml", new ClassLoaderResourceAccessor(), database); liquibase.dropAll(); liquibase.getDatabase().close(); } catch (Exception e) { e.printStackTrace(); } }
Example 7
Source File: DbSchemaDrop.java From flowable-engine with Apache License 2.0 | 5 votes |
public static void main(String[] args) { try { ContentEngine contentEngine = ContentEngines.getDefaultContentEngine(); DataSource dataSource = contentEngine.getContentEngineConfiguration().getDataSource(); DatabaseConnection connection = new JdbcConnection(dataSource.getConnection()); Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection); database.setDatabaseChangeLogTableName(ContentEngineConfiguration.LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogTableName()); database.setDatabaseChangeLogLockTableName(ContentEngineConfiguration.LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogLockTableName()); if (StringUtils.isNotEmpty(contentEngine.getContentEngineConfiguration().getDatabaseSchema())) { database.setDefaultSchemaName(contentEngine.getContentEngineConfiguration().getDatabaseSchema()); database.setLiquibaseSchemaName(contentEngine.getContentEngineConfiguration().getDatabaseSchema()); } if (StringUtils.isNotEmpty(contentEngine.getContentEngineConfiguration().getDatabaseCatalog())) { database.setDefaultCatalogName(contentEngine.getContentEngineConfiguration().getDatabaseCatalog()); database.setLiquibaseCatalogName(contentEngine.getContentEngineConfiguration().getDatabaseCatalog()); } Liquibase liquibase = new Liquibase("org/flowable/content/db/liquibase/flowable-content-db-changelog.xml", new ClassLoaderResourceAccessor(), database); liquibase.dropAll(); liquibase.getDatabase().close(); } catch (Exception e) { e.printStackTrace(); } }
Example 8
Source File: DbSchemaDrop.java From flowable-engine with Apache License 2.0 | 5 votes |
public static void main(String[] args) { try { EventRegistryEngine eventRegistryEngine = EventRegistryEngines.getDefaultEventRegistryEngine(); EventRegistryEngineConfiguration eventRegistryEngineConfiguration = eventRegistryEngine.getEventRegistryEngineConfiguration(); DataSource dataSource = eventRegistryEngineConfiguration.getDataSource(); DatabaseConnection connection = new JdbcConnection(dataSource.getConnection()); Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection); database.setDatabaseChangeLogTableName(EventRegistryEngineConfiguration.LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogTableName()); database.setDatabaseChangeLogLockTableName(EventRegistryEngineConfiguration.LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogLockTableName()); if (StringUtils.isNotEmpty(eventRegistryEngineConfiguration.getDatabaseSchema())) { database.setDefaultSchemaName(eventRegistryEngineConfiguration.getDatabaseSchema()); database.setLiquibaseSchemaName(eventRegistryEngineConfiguration.getDatabaseSchema()); } if (StringUtils.isNotEmpty(eventRegistryEngineConfiguration.getDatabaseCatalog())) { database.setDefaultCatalogName(eventRegistryEngineConfiguration.getDatabaseCatalog()); database.setLiquibaseCatalogName(eventRegistryEngineConfiguration.getDatabaseCatalog()); } Liquibase liquibase = new Liquibase("org/flowable/eventregistry/db/liquibase/flowable-eventregistry-db-changelog.xml", new ClassLoaderResourceAccessor(), database); liquibase.dropAll(); liquibase.getDatabase().close(); } catch (Exception e) { e.printStackTrace(); } }
Example 9
Source File: SQLEntityStoreMixin.java From attic-polygene-java with Apache License 2.0 | 5 votes |
private void applyLiquibaseChangelog( SQLDialect dialect ) throws SQLException, LiquibaseException { Liquibase liquibase = liquibaseService.newConnectedLiquibase(); Database db = liquibase.getDatabase(); db.setObjectQuotingStrategy( ObjectQuotingStrategy.QUOTE_ALL_OBJECTS ); try { if( !dialect.equals( SQLDialect.SQLITE ) ) { if( db.supportsSchemas() ) { db.setDefaultSchemaName( schema.getName() ); db.setLiquibaseSchemaName( schema.getName() ); } if( db.supportsCatalogs() ) { db.setDefaultCatalogName( schema.getName() ); db.setLiquibaseCatalogName( schema.getName() ); } } liquibase.getChangeLogParameters().set( TABLE_NAME_LIQUIBASE_PARAMETER, table.getName() ); liquibase.update( new Contexts() ); } finally { db.close(); } }
Example 10
Source File: LiquibaseBasedSchemaManager.java From flowable-engine with Apache License 2.0 | 4 votes |
protected Liquibase createLiquibaseInstance(LiquibaseDatabaseConfiguration databaseConfiguration) throws SQLException { Connection jdbcConnection = null; boolean closeConnection = false; try { CommandContext commandContext = Context.getCommandContext(); if (commandContext == null) { jdbcConnection = databaseConfiguration.getDataSource().getConnection(); closeConnection = true; } else { jdbcConnection = commandContext.getSession(DbSqlSession.class).getSqlSession().getConnection(); } // A commit is needed here, because one of the things that Liquibase does when acquiring its lock // is doing a rollback, which removes all changes done so far. // For most databases, this is not a problem as DDL statements are not transactional. // However for some (e.g. sql server), this would remove all previous statements, which is not wanted, // hence the extra commit here. if (!jdbcConnection.getAutoCommit()) { jdbcConnection.commit(); } DatabaseConnection connection = new JdbcConnection(jdbcConnection); Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection); database.setDatabaseChangeLogTableName(changeLogPrefix + database.getDatabaseChangeLogTableName()); database.setDatabaseChangeLogLockTableName(changeLogPrefix + database.getDatabaseChangeLogLockTableName()); String databaseSchema = databaseConfiguration.getDatabaseSchema(); if (StringUtils.isNotEmpty(databaseSchema)) { database.setDefaultSchemaName(databaseSchema); database.setLiquibaseSchemaName(databaseSchema); } String databaseCatalog = databaseConfiguration.getDatabaseCatalog(); if (StringUtils.isNotEmpty(databaseCatalog)) { database.setDefaultCatalogName(databaseCatalog); database.setLiquibaseCatalogName(databaseCatalog); } return new Liquibase(changeLogFile, new ClassLoaderResourceAccessor(), database); } catch (Exception e) { // We only close the connection if an exception occurred, otherwise the Liquibase instance cannot be used if (jdbcConnection != null && closeConnection) { jdbcConnection.close(); } throw new FlowableException("Error creating " + context + " liquibase instance", e); } }