If you haven’t already, sign up for a Neon account and create a project. This will provision a new serverless PostgreSQL database. Note your project’s connection details.
Connect to your Neon database using the provided SQL Editor or any compatible psql client.Run the following command to set the wal_level to logical, which is required for CDC.
Copy
Ask AI
ALTER SYSTEM SET wal_level = logical;
Your Neon project may need to restart for this change to apply.
Create or alter a user, granting them the necessary roles for replication.
Copy
Ask AI
-- Create a new user with a secure passwordCREATE USER <user_name> WITH REPLICATION LOGIN PASSWORD '<your_password>';-- Or, assign attributes to an existing userALTER USER <user_name> WITH REPLICATION LOGIN;
Finally, grant the user the necessary privileges on the database and schemas you want to capture changes from.
Copy
Ask AI
-- Grant connection access to the databaseGRANT CONNECT ON DATABASE <database_name> TO <user_name>;-- Grant usage on the schemaGRANT USAGE ON SCHEMA <schema_name> TO <user_name>;-- Grant select on all tables in the schemaGRANT SELECT ON ALL TABLES IN SCHEMA <schema_name> TO <user_name>;