Skip to content

Commit

Permalink
add RBAC schema instructions [WiP] #27 / #31
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Jul 22, 2020
1 parent 46a2813 commit 46c45c7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.

Expand Down
18 changes: 16 additions & 2 deletions role-based-access-control.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,22 @@ 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`**:

```
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
```
Expand All @@ -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
```



Expand Down

0 comments on commit 46c45c7

Please sign in to comment.