DROP DATABASE IF EXISTS adam_db;
DROP DATABASE IF EXISTS bety_db;

CREATE DATABASE adam_db OWNER postgres;
CREATE DATABASE bety_db OWNER postgres;

\c adam_db
CREATE TABLE adams_numbers(key TEXT, value INTEGER);
INSERT INTO adams_numbers VALUES ('one', 1), ('two', 2);

\c bety_db
CREATE EXTENSION IF NOT EXISTS postgres_fdw WITH SCHEMA public;
CREATE SERVER adam_server FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host 'localhost', dbname 'adam_db', port '5432');

CREATE USER MAPPING FOR postgres SERVER adam_server OPTIONS (user 'postgres', password 'postgres');
CREATE FOREIGN TABLE IF NOT EXISTS ft_numbers (key TEXT, value INTEGER) SERVER adam_server OPTIONS (schema_name 'public', table_name 'adams_numbers');
