Skip to content

Commit a8aec89

Browse files
committed
docs(SDB): update
1 parent 89f76ca commit a8aec89

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

serverless/sql-databases/api-cli/postgrest-row-level-security.mdx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,24 @@ categories:
1616
- A Scaleway account logged into the [console](https://console.scaleway.com)
1717
- [Owner](/identity-and-access-management/iam/concepts/#owner) status or [IAM permissions](/identity-and-access-management/iam/concepts/#permission) allowing you to perform actions in the intended Organization
1818
- [Created a Serverless SQL Database](/serverless/sql-databases/how-to/create-a-database/)
19-
- [Created two applications](/identity-and-access-management/iam/how-to/create-application/) in IAM
19+
20+
## Add sample data and create PostgreSQL Row Level Security
21+
22+
1. [Connect to your Serverless SQL Database](/serverless/sql-databases/quickstart/#how-to-connect-to-a-database) with a PostgreSQL client such as `psql`:
23+
```bash
24+
psql "postgres://[user-or-application-id]:[api-secret-key]@[database-hostname]:5432/[database-name]?sslmode=require"
25+
```
26+
27+
2. Add sample data to the database using the following command:
28+
```sql
29+
CREATE TABLE pets (name varchar, keeper varchar, id int);
30+
INSERT INTO pets VALUES ('Stuart','role_admin',1),('Nemo','role_admin',2),('Alfie','role_readwrite',3),('Peanut','role_readwrite',4);
31+
```
32+
33+
3. Run the command below to enable **Row Level Security**:
34+
```sql
35+
ALTER TABLE pets ENABLE row level security;
36+
```
2037

2138
## Use Row Level Security with PostgREST
2239

0 commit comments

Comments
 (0)