CREATE TABLE ip_countries ( ip_from BIGINT NOT NULL, ip_to BIGINT NOT NULL, country CHAR(2) NOT NULL, -- country code PRIMARY KEY (ip_from, ip_to, country) ); CREATE TABLE ipv6_countries ( -- NUMERIC(39, 0) is a 39 digit *unsigned* decimal with 0 places after the decimal point (basically 39-digit non-negative integer) ip_from NUMERIC(39, 0) NOT NULL, ip_to NUMERIC(39, 0) NOT NULL, country CHAR(2) NOT NULL, -- country code PRIMARY KEY (ip_from, ip_to, country) ); COPY ip_countries (ip_from, ip_to, country) FROM '/ipdb.csv' FORMAT csv DELIMITER ',' HEADER false QUOTE '"'; COPY ipv6_countries (ip_from, ip_to, country) FROM '/ipv6db.csv' FORMAT csv DELIMITER ',' HEADER false QUOTE '"'; // file: src/lib/ip.ts // ...