CREATE TABLE event_streams (
    id SERIAL,
    event_type_id INTEGER NOT NULL,
    environment VARCHAR (64) NOT NULL,
    sns_topic_arn VARCHAR (400) NOT NULL,
    aws_lease_id INTEGER,

    PRIMARY KEY (id),
    CONSTRAINT event_streams_event_type_id_fkey FOREIGN KEY (event_type_id) REFERENCES event_types (id)
        ON UPDATE CASCADE,
    CONSTRAINT event_streams_lease_id_fkey FOREIGN KEY (aws_lease_id) REFERENCES aws_leases (id)
        ON UPDATE CASCADE,
    UNIQUE (event_type_id, environment)
);
