From 46c45c7966080440225a103e39fdf5e5c429e55f Mon Sep 17 00:00:00 2001 From: nelsonic Date: Wed, 22 Jul 2020 18:41:36 +0100 Subject: [PATCH] add RBAC schema instructions [WiP] #27 / #31 --- README.md | 3 +-- role-based-access-control.md | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c0b83831..555b2d9c 100644 --- a/README.md +++ b/README.md @@ -173,7 +173,6 @@ And for sending emails you will need the `SECRET_KEY_BASE` and `EMAIL_APP_URL` defined. - ### 4. Create and migrate your database: > Ensure that PostgreSQL is running @@ -190,7 +189,7 @@ mix ecto.setup mix phoenix.server ``` -> It may take a couple of minutes to compile the app the first time. ⏳ +> It may take a minute to compile the app the first time. ⏳ Now you can visit [`localhost:4000`](http://localhost:4000) from your browser. diff --git a/role-based-access-control.md b/role-based-access-control.md index 26014365..66ceb558 100644 --- a/role-based-access-control.md +++ b/role-based-access-control.md @@ -53,6 +53,14 @@ should learn about RBAC. ## _How_? +Before creating any roles, +you will need to have a baseline schema including people +as people will be referenced by roles. + +If you don't already have these schemas/tables, +see: https://github.com/dwyl/app-mvp-phoenix#create-schemas + + Let's create the Database Schemas (Tables) to store our RBAC data, starting with **`Roles`**: @@ -60,7 +68,7 @@ starting with **`Roles`**: mix phx.gen.html Ctx Role roles name:string desc:string person_id:references:people ``` - +Next create the permissions schema: ``` mix phx.gen.html Ctx Permission permissions name:string desc:string person_id:references:people ``` @@ -71,7 +79,13 @@ Next create the **`many-to-many`** relationship between roles and permissions. mix ecto.gen.migration create_role_permissions ``` -Now create the **`many-to-many`** relationship between people and roles. + + +Now create the **`many-to-many`** relationship between people and roles: + +``` +mix ecto.gen.migration create_people_roles +```