-- schema version 7 to 8

INSERT INTO wb_gem
SELECT a.gkz, 'WLNO'
FROM AT_gem a
    LEFT JOIN wb_gem w ON w.gkz = a.gkz
WHERE a.gkz / 10000 = 3 AND w.hkid IS NULL;

INSERT INTO wb_gem
SELECT gkz, 'SLVL'
FROM AT_gem
WHERE gkz / 100 IN (617, 622, 623);

INSERT INTO wb_gem
SELECT gkz, 'SLSS'
FROM AT_gem
WHERE gkz / 100 = 610;

UPDATE wb_gem
SET hkid = 'SLVL'
WHERE gkz IN (61007, 61052, 61001, 61055, 61027, 61057, 61008, 61057);

INSERT INTO wb_gem
SELECT gkz, 'SLWS'
FROM AT_gem
WHERE gkz / 100 IN (603, 616) OR gkz IN (60101, 60663, 60651, 60659, 60664, 60647, 60641, 60639, 60665, 60669, 60618, 60629, 60608, 60670, 60624, 60660, 60656, 60655);

INSERT INTO wb_gem
SELECT g.gkz, 'SLVL'
FROM AT_gem g
    LEFT JOIN wb_gem w ON w.gkz = g.gkz
WHERE g.gkz / 100 = 606 AND w.hkid IS NULL;

INSERT INTO wb_gem
SELECT g.gkz, 'SLST'
FROM AT_gem g
    LEFT JOIN wb_gem w ON w.gkz = g.gkz
WHERE g.gkz / 10000 = 6 AND w.hkid IS NULL;

INSERT INTO wb_gem
SELECT gkz, 'BLOO'
FROM AT_gem
WHERE gkz / 10000 = 4;

INSERT INTO wb_gem
SELECT gkz, 'BLKA'
FROM AT_gem
WHERE gkz / 10000 = 2;

INSERT INTO wb_gem
SELECT gkz, 'BLSB'
FROM AT_gem
WHERE gkz / 10000 = 5;

INSERT INTO wb_gem
SELECT gkz, 'BLTI'
FROM AT_gem
WHERE gkz / 10000 = 7;

INSERT INTO wb_gem
SELECT gkz, 'BLVO'
FROM AT_gem
WHERE gkz / 10000 = 8;
