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

A new option: ignore_warnings #85

Merged
merged 1 commit into from Oct 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/main/java/org/apache/ibatis/migration/Environment.java
Expand Up @@ -32,7 +32,7 @@ public class Environment {
public static final String CHANGELOG = "changelog";

private enum SETTING_KEY {
time_zone, delimiter, script_char_set, full_line_delimiter, send_full_script, auto_commit, remove_crs, driver_path, driver, url, username, password, hook_before_up, hook_before_each_up, hook_after_each_up, hook_after_up, hook_before_down, hook_before_each_down, hook_after_each_down, hook_after_down
time_zone, delimiter, script_char_set, full_line_delimiter, send_full_script, auto_commit, remove_crs, ignore_warnings, driver_path, driver, url, username, password, hook_before_up, hook_before_each_up, hook_after_each_up, hook_after_up, hook_before_down, hook_before_each_down, hook_after_each_down, hook_after_down
}

private static final List<String> SETTING_KEYS;
Expand All @@ -53,6 +53,7 @@ private enum SETTING_KEY {
private final boolean sendFullScript;
private final boolean autoCommit;
private final boolean removeCrs;
private final boolean ignoreWarnings;
private final String driverPath;
private final String driver;
private final String url;
Expand Down Expand Up @@ -84,6 +85,7 @@ public Environment(File file) {
this.sendFullScript = Boolean.valueOf(prop.getProperty(SETTING_KEY.send_full_script.name()));
this.autoCommit = Boolean.valueOf(prop.getProperty(SETTING_KEY.auto_commit.name()));
this.removeCrs = Boolean.valueOf(prop.getProperty(SETTING_KEY.remove_crs.name()));
this.ignoreWarnings = Boolean.valueOf(prop.getProperty(SETTING_KEY.ignore_warnings.name()));

this.driverPath = prop.getProperty(SETTING_KEY.driver_path.name());
this.driver = prop.getProperty(SETTING_KEY.driver.name());
Expand Down Expand Up @@ -151,6 +153,10 @@ public boolean isRemoveCrs() {
return removeCrs;
}

public boolean isIgnoreWarnings() {
return ignoreWarnings;
}

public String getDriverPath() {
return driverPath;
}
Expand Down
Expand Up @@ -325,7 +325,7 @@ protected DatabaseOperationOption getDatabaseOperationOption() {
DatabaseOperationOption option = new DatabaseOperationOption();
option.setChangelogTable(changelogTable());
option.setStopOnError(!options.isForce());
option.setThrowWarning(!options.isForce());
option.setThrowWarning(!options.isForce() && !environment().isIgnoreWarnings());
option.setEscapeProcessing(false);
option.setAutoCommit(environment().isAutoCommit());
option.setFullLineDelimiter(environment().isFullLineDelimiter());
Expand Down
@@ -1,5 +1,5 @@
#
# Copyright 2010-2016 the original author or authors.
# Copyright 2010-2017 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -64,6 +64,9 @@ full_line_delimiter=false
# but some do.
auto_commit=false

# If set to true, warnings from the database do not interrupt migrations.
ignore_warnings=false
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this PR was merged, the default value was false. It was changed in 2f38956


# Custom driver path to allow you to centralize your driver files
# Default requires the drivers to be in the drivers directory of your
# initialized migration directory (created with "migrate init")
Expand Down
3 changes: 3 additions & 0 deletions src/site/xdoc/init.xml
Expand Up @@ -91,6 +91,9 @@ full_line_delimiter=false
# Use with JDBC drivers that can accept large
# blocks of delimited text at once.
send_full_script=false
# If set to true, warnings from the database
# do not interrupt migrations.
ignore_warnings=false
# Custom driver path to avoid copying your drivers
# driver_path=]]></source>
</subsection>
Expand Down
4 changes: 2 additions & 2 deletions src/site/xdoc/migrate.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright 2010-2016 the original author or authors.
Copyright 2010-2017 the original author or authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -34,7 +34,7 @@
[--template=<path to template>]
--path=<directory> Path to repository. Default current working directory.
--env=<environment> Environment to configure. Default environment is 'development'.
--force Forces script to continue even if SQL errors are encountered.
--force Forces script to continue even if SQL errors or warnings are encountered.
--help Displays this usage message.
--trace Shows additional error details (if any).
--template (Optional) Specify template to be used with ‘new'command
Expand Down