Skip to content

Commit 81a1cdc

Browse files
committed
Add migration to resolve bug remains
1 parent f654bd9 commit 81a1cdc

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

libpretixsync/src/main/java/eu/pretix/libpretixsync/db/Migrations.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
public class Migrations {
1717
private static EntityModel model = Models.DEFAULT;
18-
public static int CURRENT_VERSION = 106;
18+
public static int CURRENT_VERSION = 107;
1919

2020
private static void createVersionTable(Connection c, int version) throws SQLException {
2121
Statement s2 = c.createStatement();
@@ -434,6 +434,11 @@ public static void migrate(DataSource dataSource, boolean dbIsNew) throws SQLExc
434434
execIgnore(c, "ALTER TABLE receiptline ADD tax_code TEXT NULL;", new String[] {"duplicate column name", "already exists", "existiert bereits"});
435435
updateVersionTable(c, 106);
436436
}
437+
if (db_version < 107) {
438+
// Version 4.3.6 contained a bug that wrote stringified null into this column.
439+
execIgnore(c, "UPDATE ReceiptLine SET tax_code = NULL WHERE tax_code = 'null';", new String[] {"no such column", "existiert", "syntax error"});
440+
updateVersionTable(c, 107);
441+
}
437442

438443
// Note that the Android app currently does not use these queries!
439444

@@ -482,6 +487,11 @@ public static void android_manual_migrations(Connection c, int oldVersion, int n
482487
execIgnore(c, "ALTER TABLE settings DROP COLUMN covid_certificates_allow_vaccinated_products;", new String[] {"no such column", "existiert", "syntax error"});
483488
updateVersionTable(c, 105);
484489
}
490+
if (oldVersion < 107 && newVersion >= 107) {
491+
// Version 4.3.6 contained a bug that wrote stringified null into this column.
492+
execIgnore(c, "UPDATE ReceiptLine SET tax_code = NULL WHERE tax_code = 'null';", new String[] {"no such column", "existiert", "syntax error"});
493+
updateVersionTable(c, 107);
494+
}
485495
}
486496

487497
private static void create_drop(DataSource dataSource) {

libpretixsync/src/main/sqldelight/common/eu/pretix/libpretixsync/sqldelight/ReceiptLine.sq

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,4 @@ VALUES (
105105
?,
106106
?,
107107
?
108-
);
108+
);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
UPDATE ReceiptLine SET tax_code = NULL WHERE tax_code = 'null';

0 commit comments

Comments
 (0)