BEGIN;

DROP TABLE IF EXISTS persons;

CREATE TABLE persons (
    id SERIAL PRIMARY KEY,
    first_name TEXT NOT NULL,
    last_name TEXT NOT NULL,
    grade INTEGER NOT NULL,
    parent_name TEXT NOT NULL,
    parent_phone_number TEXT NOT NULL,
    checked_in BOOLEAN NOT NULL DEFAULT FALSE,
    inside BOOLEAN NOT NULL DEFAULT FALSE,
    visitor BOOLEAN NOT NULL DEFAULT FALSE,
    sleeping_spot BOOLEAN NOT NULL DEFAULT FALSE
);

CREATE INDEX idx_persons_first_name_trgm ON persons USING GIN (first_name gin_trgm_ops);
CREATE INDEX idx_persons_last_name_trgm ON persons USING GIN (last_name gin_trgm_ops);
CREATE INDEX idx_persons_parent_name_trgm ON persons USING GIN (parent_name gin_trgm_ops);
CREATE INDEX idx_persons_parent_phone_number ON persons (parent_phone_number);

COMMIT;
