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

Rebased remove_db_build branch #1002

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
289 changes: 151 additions & 138 deletions pom.xml

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/main/java/de/rwth/idsg/steve/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package de.rwth.idsg.steve;

import de.rwth.idsg.steve.utils.FlywayMigrationRunner;
import lombok.extern.slf4j.Slf4j;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
Expand All @@ -44,6 +45,8 @@ public Application() {
DateTimeZone.setDefault(DateTimeZone.forID(sc.getTimeZoneId()));
log.info("Date/time zone of the application is set to {}. Current date/time: {}", sc.getTimeZoneId(), DateTime.now());

FlywayMigrationRunner.run(sc);

switch (sc.getProfile()) {
case DEV:
delegate = new SteveDevStarter();
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/de/rwth/idsg/steve/SteveConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ public static class DB {
private final String userName;
private final String password;
private final boolean sqlLogging;

public String getJdbcUrl() {
return "jdbc:mysql://" + ip + ":" + port + "/" + schema;
}
}

// Credentials for Web interface access
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private void initDataSource() {
HikariConfig hc = new HikariConfig();

// set standard params
hc.setJdbcUrl("jdbc:mysql://" + dbConfig.getIp() + ":" + dbConfig.getPort() + "/" + dbConfig.getSchema());
hc.setJdbcUrl(dbConfig.getJdbcUrl());
hc.setUsername(dbConfig.getUserName());
hc.setPassword(dbConfig.getPassword());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* SteVe - SteckdosenVerwaltung - https://github.com/steve-community/steve
* Copyright (C) 2013-2019 RWTH Aachen University - Information Systems - Intelligent Distributed Systems Group (IDSG).
* Copyright (C) 2013-2021 RWTH Aachen University - Information Systems - Intelligent Distributed Systems Group (IDSG).
* All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
Expand Down
61 changes: 61 additions & 0 deletions src/main/java/de/rwth/idsg/steve/utils/FlywayMigrationRunner.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* SteVe - SteckdosenVerwaltung - https://github.com/steve-community/steve
* Copyright (C) 2013-2021 RWTH Aachen University - Information Systems - Intelligent Distributed Systems Group (IDSG).
* All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.rwth.idsg.steve.utils;

import de.rwth.idsg.steve.SteveConfiguration;
import org.flywaydb.core.api.configuration.FluentConfiguration;

/**
* @author Sevket Goekay <[email protected]>
* @since 08.08.2021
*/
public class FlywayMigrationRunner {

private static final String INIT_SQL = "SET default_storage_engine=InnoDB;";
private static final String BOOKKEEPING_TABLE = "schema_version";
private static final String LOCATION_OF_MIGRATIONS = "db/migration";

public static void run(SteveConfiguration sc) {
try {
getConfig(sc.getDb()).load().migrate();
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
}

/**
* This configuration should be kept in-sync with the one of the flyway-maven-plugin in pom.xml
*/
private static FluentConfiguration getConfig(SteveConfiguration.DB dbConfig) {
FluentConfiguration c = new FluentConfiguration();

c.initSql(INIT_SQL);
c.outOfOrder(true);
c.table(BOOKKEEPING_TABLE);
c.cleanDisabled(true);
c.schemas(dbConfig.getSchema());
c.defaultSchema(dbConfig.getSchema());
c.locations(LOCATION_OF_MIGRATIONS);
c.dataSource(dbConfig.getJdbcUrl(), dbConfig.getUserName(), dbConfig.getPassword());

return c;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* SteVe - SteckdosenVerwaltung - https://github.com/steve-community/steve
* Copyright (C) 2013-2019 RWTH Aachen University - Information Systems - Intelligent Distributed Systems Group (IDSG).
* Copyright (C) 2013-2021 RWTH Aachen University - Information Systems - Intelligent Distributed Systems Group (IDSG).
* All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* SteVe - SteckdosenVerwaltung - https://github.com/steve-community/steve
* Copyright (C) 2013-2019 RWTH Aachen University - Information Systems - Intelligent Distributed Systems Group (IDSG).
* Copyright (C) 2013-2021 RWTH Aachen University - Information Systems - Intelligent Distributed Systems Group (IDSG).
* All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* SteVe - SteckdosenVerwaltung - https://github.com/steve-community/steve
* Copyright (C) 2013-2019 RWTH Aachen University - Information Systems - Intelligent Distributed Systems Group (IDSG).
* Copyright (C) 2013-2021 RWTH Aachen University - Information Systems - Intelligent Distributed Systems Group (IDSG).
* All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* SteVe - SteckdosenVerwaltung - https://github.com/steve-community/steve
* Copyright (C) 2013-2019 RWTH Aachen University - Information Systems - Intelligent Distributed Systems Group (IDSG).
* Copyright (C) 2013-2021 RWTH Aachen University - Information Systems - Intelligent Distributed Systems Group (IDSG).
* All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* SteVe - SteckdosenVerwaltung - https://github.com/steve-community/steve
* Copyright (C) 2013-2019 RWTH Aachen University - Information Systems - Intelligent Distributed Systems Group (IDSG).
* Copyright (C) 2013-2021 RWTH Aachen University - Information Systems - Intelligent Distributed Systems Group (IDSG).
* All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
Expand Down
63 changes: 63 additions & 0 deletions src/main/java/jooq/steve/db/DefaultCatalog.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions src/main/java/jooq/steve/db/Indexes.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading