dbt stuff

This commit is contained in:
Pablo Martin 2023-10-29 18:40:01 +01:00
parent f9e58369ca
commit cfaa7cfecc
12 changed files with 157 additions and 2 deletions

View file

@ -10,14 +10,14 @@ This dir contains some useful bits to raise a local PostgreSQL instance with Doc
- Run the following commands to get the database ready in it's starting state
```SQL
CREATE USER transformation_user WITH ENCRYPTED PASSWORD 'transformation_user_password';
CREATE DATABASE airbnb;
-- Connect to your newly created `airbnb` database for the next commands.
CREATE SCHEMA raw;
-- The following tables should be created in the `raw` schema
CREATE TABLE raw_listings (
id INTEGER,
listing_url VARCHAR(1000),
@ -46,6 +46,22 @@ CREATE TABLE raw_hosts (
updated_at TIMESTAMP
);
CREATE SCHEMA dev;
-- Create a user for dbt activity
CREATE USER transformation_user WITH ENCRYPTED PASSWORD 'transformation_user_password';
-- Allow dbt user to read from raw schema
GRANT CONNECT ON DATABASE airbnb TO transformation_user;
GRANT USAGE ON SCHEMA raw TO transformation_user;
GRANT SELECT ON ALL TABLES IN SCHEMA raw TO transformation_user;
ALTER DEFAULT PRIVILEGES IN SCHEMA raw GRANT SELECT ON TABLES TO transformation_user;
GRANT ALL ON SCHEMA dev TO transformation_user;
ALTER SCHEMA dev owner to transformation_user;
```
After, you will have to download some CSV files with the data to populate the database. The AWS CLI commands below will download them for you: