-- Remember to increment DB_VERSION
-- in database.py on changes to this file

CREATE TABLE blocking (
    key text PRIMARY KEY, -- Contains the reversed domain name or IP in binary form
    source TEXT, -- The rule this one is based on
    type INTEGER, -- Type of the field: 1: AS, 2: domain tree, 3: domain, 4: IPv4 network, 6: IPv6 network
    updated INTEGER, -- If the row was updated during last data import (0: No, 1: Yes)
    firstparty INTEGER, -- Which blocking list this row is issued from (0: first-party, 1: multi-party)
    FOREIGN KEY (source) REFERENCES blocking(key) ON DELETE CASCADE
);
CREATE INDEX "blocking_type_updated_key" ON "blocking" (
    "type",
    "updated",
    "key"    DESC
);

-- Store various things
CREATE TABLE meta (
    key text PRIMARY KEY,
    value integer
);
