AppDbContext: Use records instead of unnamed tuples for buckets
This commit is contained in:
@ -5,12 +5,13 @@ using System.Windows;
|
||||
namespace Elwig.Helpers {
|
||||
public static class AppDbUpdater {
|
||||
|
||||
public static readonly int RequiredSchemaVersion = 9;
|
||||
public static readonly int RequiredSchemaVersion = 10;
|
||||
|
||||
private static int _versionOffset = 0;
|
||||
private static readonly Action<SqliteConnection>[] _updaters = new[] {
|
||||
UpdateDbSchema_1_To_2, UpdateDbSchema_2_To_3, UpdateDbSchema_3_To_4, UpdateDbSchema_4_To_5,
|
||||
UpdateDbSchema_5_To_6, UpdateDBSchema_6_To_7, UpdateDbSchema_7_To_8, UpdateDbSchema_8_To_9,
|
||||
UpdateDbSchema_9_To_10,
|
||||
};
|
||||
|
||||
private static void ExecuteNonQuery(SqliteConnection cnx, string sql) {
|
||||
@ -714,5 +715,26 @@ namespace Elwig.Helpers {
|
||||
END;
|
||||
""");
|
||||
}
|
||||
|
||||
private static void UpdateDbSchema_9_To_10(SqliteConnection cnx) {
|
||||
ExecuteNonQuery(cnx, "UPDATE wine_quality_level SET min_kmw = 10.6 WHERE qualid = 'RSW'");
|
||||
ExecuteNonQuery(cnx, "DROP VIEW v_area_commitment_bucket");
|
||||
ExecuteNonQuery(cnx, """
|
||||
CREATE VIEW v_area_commitment_bucket AS
|
||||
SELECT year, mgnr, bucket, area, min_kg, max_kg
|
||||
FROM v_area_commitment_bucket_strict
|
||||
WHERE attrid IS NOT NULL
|
||||
UNION ALL
|
||||
SELECT b.year, b.mgnr, b.sortid,
|
||||
SUM(b.area) AS area,
|
||||
SUM(b.min_kg) AS min_kg,
|
||||
SUM(b.upper_max_kg) AS max_kg
|
||||
FROM v_area_commitment_bucket_strict b
|
||||
LEFT JOIN wine_attribute a ON a.attrid = b.attrid
|
||||
WHERE a.strict IS NULL OR a.strict = FALSE
|
||||
GROUP BY b.year, b.mgnr, b.sortid
|
||||
ORDER BY year, mgnr, bucket;
|
||||
""");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user