CREATE ROLE repuser WITH LOGIN REPLICATION PASSWORD 'abc123';

CREATE TABLE widgets (
    id SERIAL,
    name TEXT,
    price DECIMAL,
    CONSTRAINT widgets_pkey PRIMARY KEY (id)
);

GRANT ALL PRIVILEGES ON TABLE widgets TO repuser;

INSERT INTO widgets (name, price) VALUES ('Hammer', 4.50), ('Coffee Mug', 6.20), ('Cupholder', 3.80);

CREATE PUBLICATION widgets_pub;
ALTER PUBLICATION widgets_pub ADD TABLE ONLY widgets;

SELECT pg_create_logical_replication_slot('my_slot', 'pgoutput');
