[#46] MemberHistory: Add Type to PK
This commit is contained in:
@ -9,7 +9,7 @@ namespace Elwig.Helpers {
|
|||||||
public static class AppDbUpdater {
|
public static class AppDbUpdater {
|
||||||
|
|
||||||
// Don't forget to update value in Tests/fetch-resources.bat!
|
// Don't forget to update value in Tests/fetch-resources.bat!
|
||||||
public static readonly int RequiredSchemaVersion = 20;
|
public static readonly int RequiredSchemaVersion = 21;
|
||||||
|
|
||||||
private static int VersionOffset = 0;
|
private static int VersionOffset = 0;
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ using System;
|
|||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace Elwig.Models.Entities {
|
namespace Elwig.Models.Entities {
|
||||||
[Table("member_history"), PrimaryKey("MgNr", "DateString")]
|
[Table("member_history"), PrimaryKey("MgNr", "DateString", "Type")]
|
||||||
public class MemberHistory {
|
public class MemberHistory {
|
||||||
[Column("mgnr")]
|
[Column("mgnr")]
|
||||||
public int MgNr { get; set; }
|
public int MgNr { get; set; }
|
||||||
@ -16,12 +16,12 @@ namespace Elwig.Models.Entities {
|
|||||||
set => value.ToString("yyyy-MM-dd");
|
set => value.ToString("yyyy-MM-dd");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Column("business_shares")]
|
|
||||||
public int BusinessShares { get; set; }
|
|
||||||
|
|
||||||
[Column("type")]
|
[Column("type")]
|
||||||
public required string Type { get; set; }
|
public required string Type { get; set; }
|
||||||
|
|
||||||
|
[Column("business_shares")]
|
||||||
|
public int BusinessShares { get; set; }
|
||||||
|
|
||||||
[Column("comment")]
|
[Column("comment")]
|
||||||
public string? Comment { get; set; }
|
public string? Comment { get; set; }
|
||||||
|
|
||||||
|
16
Elwig/Resources/Sql/20-21.sql
Normal file
16
Elwig/Resources/Sql/20-21.sql
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
-- schema version 20 to 21
|
||||||
|
|
||||||
|
DROP TABLE member_history;
|
||||||
|
CREATE TABLE member_history (
|
||||||
|
mgnr INTEGER NOT NULL,
|
||||||
|
date TEXT NOT NULL CHECK (date REGEXP '^[1-9][0-9]{3}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$') DEFAULT CURRENT_DATE,
|
||||||
|
type TEXT NOT NULL CHECK (type REGEXP '^[a-z_]+$'),
|
||||||
|
|
||||||
|
business_shares INTEGER NOT NULL,
|
||||||
|
comment TEXT DEFAULT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT pk_member_history PRIMARY KEY (mgnr, date, type),
|
||||||
|
CONSTRAINT fk_member_history_member FOREIGN KEY (mgnr) REFERENCES member (mgnr)
|
||||||
|
ON UPDATE CASCADE
|
||||||
|
ON DELETE CASCADE
|
||||||
|
) STRICT;
|
@ -1 +1 @@
|
|||||||
curl --fail -s -L "https://elwig.at/files/create.sql?v=20" -u "elwig:ganzGeheim123!" -o "Resources\Sql\Create.sql"
|
curl --fail -s -L "https://elwig.at/files/create.sql?v=21" -u "elwig:ganzGeheim123!" -o "Resources\Sql\Create.sql"
|
||||||
|
Reference in New Issue
Block a user