Skip to content

Commit

Permalink
Rchnung min-id setzen (#579)
Browse files Browse the repository at this point in the history
* Rchnung min-id setzen

* Update umbenannt
  • Loading branch information
lenilsas authored Jan 23, 2025
1 parent 43f32b7 commit c9164fd
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 3 deletions.
51 changes: 51 additions & 0 deletions src/de/jost_net/JVerein/server/DDLTool/Updates/Update0459.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**********************************************************************
* 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 <http://www.gnu.org/licenses/>.
*
**********************************************************************/
package de.jost_net.JVerein.server.DDLTool.Updates;

import java.sql.Connection;

import de.jost_net.JVerein.server.DDLTool.AbstractDDLUpdate;
import de.willuhn.util.ApplicationException;
import de.willuhn.util.ProgressMonitor;

public class Update0459 extends AbstractDDLUpdate
{
public Update0459(String driver, ProgressMonitor monitor, Connection conn)
{
super(driver, monitor, conn);
}

@Override
public void run() throws ApplicationException
{
{
// Autoincrement von Rechnung auf den maximalen Zähler aus Formular setzen
// so gibt es eine fortlaufende Rechnungsnummer bei verwendung der
// Rechnung-ID
if (getDriver() == DRIVER.H2)
{
execute(
"SET @max_id = (SELECT MAX(zaehler)+1 FROM formular WHERE art = 2);"
+ "ALTER TABLE rechnung ALTER COLUMN id RESTART WITH @max_id;");
}
if (getDriver() == DRIVER.MYSQL)
{
execute(
"SET @max_id = (SELECT MAX(zaehler)+1 FROM formular WHERE art = 2);"
+ "SET @sql = CONCAT('ALTER TABLE rechnung AUTO_INCREMENT = ', @max_id);"
+ "PREPARE st FROM @sql; EXECUTE st;");
}
}
}
}
11 changes: 8 additions & 3 deletions src/de/jost_net/JVerein/server/JVereinUpdateProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -6892,9 +6892,14 @@ private void update0339(Connection conn) throws ApplicationException
private void update0340(Connection conn) throws ApplicationException
{
Map<String, String> statements = new HashMap<String, String>();
String sql = alterColumn("einstellung", "name",
"VARCHAR(70) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci");
statements.put(driver, sql);
// Update fuer H2
statements.put(DBSupportH2Impl.class.getName(),
alterColumn("einstellung", "name", "VARCHAR(70)"));

// Update fuer MySQL
statements.put(DBSupportMySqlImpl.class.getName(), alterColumn(
"einstellung", "name",
"VARCHAR(70) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci"));
execute(conn, statements, 340);
}

Expand Down

0 comments on commit c9164fd

Please sign in to comment.