Using country_code as PK
This commit is contained in:
@ -43,11 +43,11 @@ CREATE TABLE currency (
|
||||
) STRICT;
|
||||
|
||||
CREATE TABLE postal_dest (
|
||||
country TEXT NOT NULL,
|
||||
country INTEGER NOT NULL,
|
||||
id TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT pk_postal_dest PRIMARY KEY (country, id),
|
||||
CONSTRAINT fk_postal_dest_country FOREIGN KEY (country) REFERENCES country (alpha2)
|
||||
CONSTRAINT fk_postal_dest_country FOREIGN KEY (country) REFERENCES country (num)
|
||||
ON UPDATE CASCADE
|
||||
ON DELETE RESTRICT
|
||||
) STRICT;
|
||||
@ -122,7 +122,7 @@ CREATE TABLE AT_plz_dest (
|
||||
plz INTEGER NOT NULL CHECK (plz >= 1000 AND plz <= 9999),
|
||||
okz INTEGER NOT NULL,
|
||||
|
||||
country TEXT NOT NULL GENERATED ALWAYS AS ('AT') VIRTUAL,
|
||||
country INTEGER NOT NULL GENERATED ALWAYS AS (40) VIRTUAL,
|
||||
id TEXT NOT NULL GENERATED ALWAYS AS (plz * 100000 + okz) STORED,
|
||||
|
||||
dest TEXT NOT NULL,
|
||||
@ -248,7 +248,7 @@ CREATE TABLE branch (
|
||||
zwstid TEXT NOT NULL CHECK (zwstid REGEXP '^[A-Z]$'),
|
||||
name TEXT NOT NULL,
|
||||
|
||||
country TEXT DEFAULT NULL,
|
||||
country INTEGER DEFAULT NULL,
|
||||
postal_dest TEXT DEFAULT NULL,
|
||||
address TEXT DEFAULT NULL,
|
||||
|
||||
@ -307,7 +307,7 @@ CREATE TABLE member (
|
||||
iban TEXT CHECK (iban REGEXP '^[A-Z]{2}[0-9]{2}[A-Z0-9]{8,30}$') DEFAULT NULL,
|
||||
bic TEXT CHECK (bic REGEXP '^[A-Z0-9]{4}[A-Z]{2}[A-Z0-9]{2}([A-Z0-9]{3})?$') DEFAULT NULL,
|
||||
|
||||
country TEXT NOT NULL,
|
||||
country INTEGER NOT NULL,
|
||||
postal_dest TEXT NOT NULL,
|
||||
address TEXT NOT NULL,
|
||||
|
||||
@ -340,7 +340,7 @@ CREATE TABLE member_billing_address (
|
||||
mgnr INTEGER NOT NULL,
|
||||
|
||||
name TEXT NOT NULL,
|
||||
country TEXT NOT NULL,
|
||||
country INTEGER NOT NULL,
|
||||
postal_dest TEXT NOT NULL,
|
||||
address TEXT NOT NULL,
|
||||
|
||||
|
@ -31,6 +31,8 @@ GROSSLAGE_MAP: Optional[Dict[int, int]] = None
|
||||
MEMBER_MAP: Optional[Dict[int, Dict[str, Any]]] = None
|
||||
GROSSLAGE_KG_MAP: Optional[Dict[int, int]] = None
|
||||
|
||||
AUSTRIA = 40
|
||||
|
||||
QUAL_MAP: Dict[int, str] = {
|
||||
0: 'WEI',
|
||||
1: 'RSW',
|
||||
@ -504,7 +506,7 @@ def migrate_branches(in_dir: str, out_dir: str) -> None:
|
||||
tel, mob = normalize_phone_nr(b['Telefon']), None
|
||||
if tel and tel[4] == '6':
|
||||
mob, tel = tel, None
|
||||
f.row(b['Kennbst'], b['Name'].strip().title(), 'AT', postal_dest, address,
|
||||
f.row(b['Kennbst'], b['Name'].strip().title(), AUSTRIA, postal_dest, address,
|
||||
tel, normalize_phone_nr(b['Telefax']), mob)
|
||||
|
||||
|
||||
@ -846,7 +848,7 @@ def migrate_members(in_dir: str, out_dir: str) -> None:
|
||||
m['Geburtsjahr'], m['Eintrittsdatum'], m['Austrittsdatum'], m['Geschäftsanteile1'] or 0,
|
||||
m['BHKontonummer'], zwstid, bnr, ustid,
|
||||
m['Volllieferant'] or False, m['Buchführend'] or False, funktionaer, active,
|
||||
iban, bic, 'AT', postal_dest, address or '-', email, kgnr, m['Anmerkung']
|
||||
iban, bic, AUSTRIA, postal_dest, address or '-', email, kgnr, m['Anmerkung']
|
||||
)
|
||||
|
||||
phone_1: Optional[str] = m['Telefon']
|
||||
@ -982,7 +984,7 @@ def migrate_members(in_dir: str, out_dir: str) -> None:
|
||||
'default_kgnr': kgnr
|
||||
}
|
||||
if billing_name:
|
||||
f_mba.row(mgnr, billing_name, 'AT', postal_dest, address or '-')
|
||||
f_mba.row(mgnr, billing_name, AUSTRIA, postal_dest, address or '-')
|
||||
|
||||
|
||||
def migrate_area_commitments(in_dir: str, out_dir: str) -> None:
|
||||
|
Reference in New Issue
Block a user