Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate change log using java api fails #129

Open
amergey opened this issue Apr 21, 2023 · 0 comments
Open

generate change log using java api fails #129

amergey opened this issue Apr 21, 2023 · 0 comments

Comments

@amergey
Copy link

amergey commented Apr 21, 2023

Environment

Liquibase Version: 4.21.1

Liquibase Integration & Version: java

Liquibase Extension(s) & Version: 4.21.1

Database Vendor & Version: Vrtica 12.0.4-0

Operating System Type & Version: ubuntu 22.04.2

Description

It does not seem possible to generate change log for a vertica database using java api

Steps To Reproduce

Executing this code

Map<String, Object> config = new HashMap<>();
		Scope.child(config, () -> {
			try (Connection connection = provider.getDataSource().getConnection()) {
				Database database = Scope.getCurrentScope().getSingleton(DatabaseFactory.class)
						.findCorrectDatabaseImplementation(new JdbcConnection(connection));
				try (Liquibase liquibase = new liquibase.Liquibase(ddlConfigPath, accessor, database)) {
					File file = new File(ddlConfigPath);
					try (PrintStream ps = new PrintStream(file)) {
						CatalogAndSchema cat = database.getDefaultSchema();
						config.put(SCHEMA_CONFIG, cat.getSchemaName());

						Set<Class<? extends DatabaseObject>> finalCompareTypes = null;
						CompareControl compareControl = new CompareControl(
								new CompareControl.SchemaComparison[] { new CompareControl.SchemaComparison(cat, cat) },
								finalCompareTypes);

						new CommandScope(GenerateChangelogCommandStep.COMMAND_NAME[0])
						.addArgumentValue(PreCompareCommandStep.OBJECT_CHANGE_FILTER_ARG, getObjectChangeFilter(((AbstractDataSourceContainer<?>) provider).getType()))
						.addArgumentValue(DiffOutputControlCommandStep.INCLUDE_CATALOG_ARG, false)
						.addArgumentValue(DiffOutputControlCommandStep.INCLUDE_SCHEMA_ARG, false)
						.addArgumentValue(DiffOutputControlCommandStep.INCLUDE_TABLESPACE_ARG, false)
						.addArgumentValue(GenerateChangelogCommandStep.CHANGELOG_FILE_ARG,
								liquibase.getChangeLogFile())
						.addArgumentValue(PreCompareCommandStep.COMPARE_CONTROL_ARG, compareControl)
						.addArgumentValue(DbUrlConnectionCommandStep.DATABASE_ARG, liquibase.getDatabase())
						.addArgumentValue(PreCompareCommandStep.SNAPSHOT_TYPES_ARG, null)
						.addArgumentValue(GenerateChangelogCommandStep.OVERWRITE_OUTPUT_FILE_ARG, true)

						.setOutput(ps).execute();
					}
				}
			} catch (SQLException e) {
				throw new RuntimeException(e);
			}
		});

Actual Behavior

fails with

liquibase.exception.CommandExecutionException: liquibase.exception.DatabaseException: java.sql.SQLException: [Vertica][VJDBC](4650) ERROR: Schema "information_schema" does not exist
	at liquibase.command.CommandScope.execute(CommandScope.java:235)

Expected/Desired Behavior

it should succeed an generates the snapshot

Additional Context

VerticaDatabase overrides AbstractJdbcDatabase without overriding getSystemSchema()
but even with that it seems the generate snapshot command is always generating snapshot through JdbcDatabaseSnapshot (see liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(DatabaseObject[], Database, SnapshotControl) ) which I think is not working with Vertica

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant