Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Towards v11.2.0 #666

Merged
merged 20 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions diagrams/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ You can go download erd from https://github.com/BurntSushi/erd/releases and then
./erd_static-x86-64 -i diagrams/film.er -o docs/_static/film.png
```

The fonts used belong to the GNU FreeFont family. You can download them here: http://ftp.gnu.org/gnu/freefont/

## LaTeX

The schema structure diagram is done with LaTeX. You can use a GUI like https://www.mathcha.io/editor to create the .tex file.
Expand Down
15 changes: 15 additions & 0 deletions diagrams/boxoffice.er
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
entity {font: "FreeSans"}
relationship {font: "FreeMono"}

[Box_Office]
*bo_date
*+film_id
gross_revenue

[Films]
*id
+director_id
title
`...`

Box_Office +--1 Films
5 changes: 5 additions & 0 deletions diagrams/employees.er
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Build using: -e ortho

entity {font: "FreeSans"}
relationship {font: "FreeMono"}

[Employees]
*id
first_name
Expand Down
11 changes: 11 additions & 0 deletions diagrams/film.er
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
entity {font: "FreeSans"}
relationship {font: "FreeSerif"}

[Films]
*id
+director_id
Expand Down Expand Up @@ -31,10 +34,18 @@ year
*+film_id
rank

[Technical_Specs]
*+film_id
runtime
camera
sound

Roles *--1 Actors
Roles *--1 Films

Nominations *--1 Competitions
Nominations *--1 Films

Films *--1 Directors

Films 1--1 Technical_Specs
5 changes: 5 additions & 0 deletions diagrams/orders.er
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Build using: -e ortho

entity {font: "FreeSans"}
relationship {font: "FreeMono"}

[Addresses]
*id
name
Expand Down
16 changes: 16 additions & 0 deletions diagrams/premieres.er
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
entity {font: "FreeSans"}
relationship {font: "FreeMono"}

[Premieres]
*id
location
date
+film_id

[Films]
*id
+director_id
title
`...`

Premieres *--1 Films
5 changes: 5 additions & 0 deletions diagrams/presidents.er
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Build using: -e ortho

entity {font: "FreeSans"}
relationship {font: "FreeMono"}

[Presidents]
*id
first_name
Expand Down
5 changes: 5 additions & 0 deletions diagrams/users.er
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Build using: -e ortho

entity {font: "FreeSans"}
relationship {font: "FreeMono"}

[Users]
*id
first_name
Expand Down
Binary file added docs/_static/boxoffice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/employees.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/film.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/orders.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/presidents.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/_static/users.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/ecosystem.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Community Tutorials

* `Build data-driven applications with Workers and PostgreSQL <https://developers.cloudflare.com/workers/tutorials/postgres/>`_ - A tutorial on how to integrate with PostgREST and PostgreSQL using Cloudflare Workers.

* `A poor man's API <https://blog.frankel.ch/poor-man-api>`_ - Shows how to integrate PostgREST with Apache APISIX as an alternative to Nginx.

.. _templates:

Templates
Expand Down
142 changes: 12 additions & 130 deletions docs/explanations/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ You can also use your OS package manager.
choco install postgrest
scoop install postgrest


.. _pg-dependency:

Supported PostgreSQL versions
=============================

=============== =================================
**Supported** PostgreSQL >= 9.6
=============== =================================

PostgREST works with all PostgreSQL versions starting from 9.6.

Running PostgREST
=================

Expand Down Expand Up @@ -101,13 +113,6 @@ For a complete reference of the configuration file, see :ref:`configuration`.

To test that the system path is set correctly, run ``pg_config`` from the command line. You should see it output a list of paths.

.. _pg-dependency:

PostgreSQL dependency
---------------------

To use PostgREST you will need an underlying database. We require PostgreSQL 9.6 or greater. You can use something like `Amazon RDS <https://aws.amazon.com/rds/>`_ but installing your own locally is cheaper and more convenient for development. You can also run PostgreSQL in a :ref:`docker container<pg-in-docker>`.

Docker
======

Expand Down Expand Up @@ -256,126 +261,3 @@ You can build PostgREST from source with `Stack <https://github.com/commercialha
- `--install-ghc` flag is only needed for the first build and can be omitted in the subsequent builds.

* Check that the server is installed: :code:`postgrest --help`.

.. _deploy_heroku:

Deploying to Heroku
===================

1. Log into Heroku using the `Heroku CLI <https://devcenter.heroku.com/articles/heroku-cli>`_:

.. code-block:: bash

# If you have multiple Heroku accounts, use flag '--interactive' to switch between them
heroku login --interactive


2. Create a new Heroku app using the PostgREST buildpack:

.. code-block:: bash

mkdir ${YOUR_APP_NAME}
cd ${YOUR_APP_NAME}
git init .

heroku apps:create ${YOUR_APP_NAME} --buildpack https://github.com/PostgREST/postgrest-heroku.git
heroku git:remote -a ${YOUR_APP_NAME}

3. Create a new Heroku PostgreSQL add-on attached to the app and keep notes of the assigned add-on name (e.g. :code:`postgresql-curly-58902`) referred later as ${HEROKU_PG_DB_NAME}

.. code-block:: bash

heroku addons:create heroku-postgresql:standard-0 -a ${YOUR_APP_NAME}
# wait until the add-on is available
heroku pg:wait -a ${YOUR_APP_NAME}

4. Create the necessary user roles according to the
`PostgREST documentation <https://postgrest.org/en/stable/auth.html>`_:

.. code-block:: bash

heroku pg:credentials:create --name api_user -a ${YOUR_APP_NAME}
# use the following command to ensure the new credential state is active before attaching it
heroku pg:credentials -a ${YOUR_APP_NAME}

heroku addons:attach ${HEROKU_PG_DB_NAME} --credential api_user -a ${YOUR_APP_NAME}

5. Connect to the PostgreSQL database and create some sample data:

.. code-block:: bash

heroku psql -a ${YOUR_APP_NAME}

.. code-block:: postgres

# from the psql command prompt execute the following commands:
create schema api;

create table api.todos (
id serial primary key,
done boolean not null default false,
task text not null,
due timestamptz
);

insert into api.todos (task) values
('finish tutorial 0'), ('pat self on back');

grant usage on schema api to api_user;
grant select on api.todos to api_user;

6. Create the :code:`Procfile`:

.. code-block:: bash

web: PGRST_SERVER_HOST=0.0.0.0 PGRST_SERVER_PORT=${PORT} PGRST_DB_URI=${PGRST_DB_URI:-${DATABASE_URL}} ./postgrest-${POSTGREST_VER}
..

Set the following environment variables on Heroku:

.. code-block:: bash

heroku config:set POSTGREST_VER=10.0.0
heroku config:set PGRST_DB_SCHEMA=api
heroku config:set PGRST_DB_ANON_ROLE=api_user
..

PGRST_DB_URI can be set if an external database is used or if it's different from the default Heroku DATABASE_URL. This latter is used if nothing is provided.
POSTGREST_VER is mandatory to select and build the required PostgREST release.

See https://postgrest.org/en/stable/configuration.html#environment-variables for the full list of environment variables.

7. Build and deploy your app:

.. code-block:: bash

git add Procfile
git commit -m "PostgREST on Heroku"
git push heroku master
..

Your Heroku app should be live at :code:`${YOUR_APP_NAME}.herokuapp.com`

8. Test your app

From a terminal display the application logs:

.. code-block:: bash

heroku logs -t
..

From a different terminal retrieve with curl the records previously created:

.. code-block:: bash

curl https://${YOUR_APP_NAME}.herokuapp.com/todos
..

and test that any attempt to modify the table via a read-only user is not allowed:

.. code-block:: bash

curl https://${YOUR_APP_NAME}.herokuapp.com/todos -X POST \
-H "Content-Type: application/json" \
-d '{"task": "do bad thing"}'
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ PostgREST has a focused scope. It works well with other tools like Nginx. This f
Getting Support
----------------

The project has a friendly and growing community. Join our `chat room <https://gitter.im/begriffs/postgrest>`_ for discussion and help. You can also report or search for bugs/features on the Github `issues <https://github.com/PostgREST/postgrest/issues>`_ page.
The project has a friendly and growing community. For discussions, use the Github `discussions page <https://github.com/PostgREST/postgrest/discussions>`_ or join our `chat room <https://gitter.im/begriffs/postgrest>`_. You can also report or search for bugs/features on the Github `issues <https://github.com/PostgREST/postgrest/issues>`_ page.

.. toctree::
:glob:
Expand Down
Loading