Skip to content

Commit

Permalink
#2283 - ddl-generator - Refactor tidy whitespace etc
Browse files Browse the repository at this point in the history
  • Loading branch information
rbygrave committed Aug 2, 2021
1 parent 928b901 commit 7122389
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* <p>
* Typically this is run as a main method in src/test once a developer is happy
* with the next set of changes to the model.
* </p>
*
* <h3>Example: Run for a single specific platform</h3>
*
Expand All @@ -39,11 +38,9 @@
* are no longer being used by the application. These changes are called
* "pending drops" and we must explicitly specify to include these in
* a generated migration.
* </p>
* <p>
* Use <code>setGeneratePendingDrop()</code> to specify a prior migration
* that has drop column changes that we want to generate a migration for.
* </p>
*
* <h3>Example: Generate for pending drops</h3>
*
Expand All @@ -67,7 +64,6 @@ public interface DbMigration {
* Create a DbMigration implementation to use.
*/
static DbMigration create() {

Iterator<DbMigration> loader = ServiceLoader.load(DbMigration.class).iterator();
if (loader.hasNext()) {
return loader.next();
Expand All @@ -76,7 +72,7 @@ static DbMigration create() {
}

/**
* Set to false to suppress logging to System out.
* Set logging to System out (defaults to true).
*/
void setLogToSystemOut(boolean logToSystemOut);

Expand Down Expand Up @@ -105,39 +101,35 @@ static DbMigration create() {
void setMigrationPath(String migrationPath);

/**
* Set the server to use to determine the current model.
* Typically this is not called explicitly.
* Set the server to use to determine the current model. Usually this is not called explicitly.
*/
void setServer(Database database);

/**
* Set the DatabaseConfig to use. Typically this is not called explicitly.
* Set the DatabaseConfig to use. Usually this is not called explicitly.
*/
void setServerConfig(DatabaseConfig config);

/**
* Set the specific platform to generate DDL for.
* <p>
* If not set this defaults to the platform of the default database.
* </p>
*/
void setPlatform(Platform platform);

/**
* Set the specific platform to generate DDL for.
* <p>
* If not set this defaults to the platform of the default database.
* </p>
*/
void setPlatform(DatabasePlatform databasePlatform);

/**
* Set to false to turn off strict mode.
* Set to false in order to turn off strict mode.
* <p>
* Strict mode checks that a column changed to non-null on an existing table via DB migration has a default
* value specified. Set this to false if that isn't the case but it is known that all the existing rows have
* a value specified (there are no existing null values for the column).
* </p>
*/
void setStrictMode(boolean strictMode);

Expand Down Expand Up @@ -182,7 +174,6 @@ static DbMigration create() {
* Set to true if ALTER TABLE ADD FOREIGN KEY should be generated with an option to skip validation.
* <p>
* Currently this is only useful for Postgres DDL adding the <code>NOT VALID</code> option.
* </p>
*/
void setAddForeignKeySkipCheck(boolean addForeignKeySkipCheck);

Expand All @@ -191,7 +182,6 @@ static DbMigration create() {
* <p>
* Currently this is only useful for Postgres migrations adding a <code>set lock_timeout</code>
* statement to the generated database migration.
* </p>
*/
void setLockTimeout(int seconds);

Expand All @@ -200,7 +190,6 @@ static DbMigration create() {
* <p>
* Use this when you want to generate sql scripts for multiple database platforms
* from the migration (e.g. generate migration sql for MySql, Postgres and Oracle).
* </p>
*/
void addPlatform(Platform platform);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ static String nextVersion(File migDir, File modelDir, boolean initMigration) {
}

/**
* Return the last migation version given the migration directory.
* Return the last migration version given the migration directory.
*/
static String lastVersion(File migDirectory, File modelDir) {

List<MigrationVersion> versions = new ArrayList<>();

File[] sqlFiles = migDirectory.listFiles(pathname -> includeSqlFile(pathname.getName().toLowerCase()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* Exception when db migration resource path does not exist.
* <p>
* Typically the working directory or pathToResources is incorrect.
* </p>
*/
public class UnknownResourcePathException extends RuntimeException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,17 @@
public class CurrentModel {

private final SpiEbeanServer server;

private final DatabasePlatform databasePlatform;

private final DbConstraintNaming constraintNaming;

private final boolean platformTypes;

private final boolean jaxbPresent;

private final String ddlHeader;
private final DdlOptions ddlOptions = new DdlOptions();

private ModelContainer model;

private ChangeSet changeSet;

private DdlWrite write;

private DdlOptions ddlOptions = new DdlOptions();

/**
* Construct with a given EbeanServer instance for DDL create all generation, not migration.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,15 @@
public class MCompoundUniqueConstraint {

private final String name;

/**
* Flag if true indicates this was specifically created for a OneToOne mapping.
*/
private final boolean oneToOne;

/**
* The columns combined to be unique.
*/
private final String[] columns;

private final String platforms;

private String[] nullableColumns;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import io.ebeaninternal.dbmigration.migration.DefaultTablespace;

/**
* Holds configuration such as the default tablespaces to use for tables,
* Holds configuration such as the default tablespace to use for tables,
* indexes, history tables etc.
*/
public class MConfiguration {
Expand Down Expand Up @@ -32,7 +32,6 @@ public class MConfiguration {
* </p>
*/
public void apply(Configuration configuration) {

DefaultTablespace defaultTablespace = configuration.getDefaultTablespace();
if (defaultTablespace != null) {
String tables = defaultTablespace.getTables();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*/
public class MIndex {

private String tableName;
private String indexName;
private final String tableName;
private final String indexName;
private String platforms;
private List<String> columns = new ArrayList<>();
private boolean unique;
Expand Down
Loading

0 comments on commit 7122389

Please sign in to comment.