Skip to content

Commit 18bfd95

Browse files
committed
docs: update postgres tenant
1 parent ca3d777 commit 18bfd95

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

content/docs/_layout.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ expand_section_list: ['Self-host']
127127

128128
#### [Webhook](/change-database/webhook)
129129

130+
#### [Issue](/change-database/issue)
131+
130132
#### [Schema Template](/administration/schema-template)
131133

132134
### [Troubleshoot 🐞](/change-database/troubleshoot)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: Issue
3+
---
4+
5+
**Issue** drives the database change workflow. You can change the issue behavior under **Project**->**Setting**.
6+
7+
## Postgres database tenant mode
8+
9+
![postgres-database-tenant](/content/docs/change-database/issue/postgres-database-tenant.webp)
10+
11+
By default, Bytebase runs the database change using the user you configure in the Bytebase instance.
12+
13+
If you turn on this setting, Bytebase will call `SET LOCAL ROLE` to the targeting PostgreSQL database OWNER
14+
before running the database change. You may need this if you have a multi-tenant service and each
15+
database has separate database OWNER.

content/docs/change-database/troubleshoot.md

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,18 @@ _Also applicable to Redshift and RisingWave_
1717

1818
Following permission errors are likely to happen if either conditions meet:
1919

20-
1. Your PostgreSQL instance in hosted in the cloud, which means the configured Bytebase database instance
20+
1. Your PostgreSQL instance is hosted in the cloud, which means the configured Bytebase database instance
2121
user does not have `superuser` role.
22-
1. Your database/table has different owners.
22+
1. The instance user you configure in Bytebase is different from the database OWNER.
23+
1. Your database/table has different OWNERs.
2324

2425
</HintBlock>
2526

2627
### ERROR: permission denied to set role xxx (SQLSTATE 42501)
2728

28-
You may encounter this error when executing the schema migration on PostgreSQL databases.
29-
30-
When Bytebase executes schema migration on PostgreSQL databases, it will not use the configured user
31-
in the instance to execute. Instead, it uses [`SET LOCAL ROLE`](https://github.com/bytebase/bytebase/blob/b79d79d81279a29ab6e9f147632f5a2631755299/backend/plugin/db/pg/pg.go#L340-L341) to switch to the
32-
targeting PostgreSQL database owner.
33-
34-
Bytebase does this because if you are creating a table, it's likely you want the created table
35-
owner to be the database owner specific to the database instead of that shared Bytebase user.
29+
This could happen if you turn on [Postgres database tenant mode](/docs/change-database/issue/#postgres-database-tenant-mode).
3630

37-
You need to grant the database owner permission to the Bytebase user configured in the PostgreSQL instance.
31+
You need to grant the database owner permission to the Bytebase user configured in your PostgreSQL instance.
3832

3933
```sql
4034
-- Suppose the Bytebase user is `bytebase`
@@ -50,16 +44,9 @@ If you use AlloyDB, the database owner must NOT be created via [Cloud IAM](https
5044

5145
### ERROR: must be owner of table xxx (SQLSTATE 42501)
5246

53-
You may encounter this error when executing the schema migration on PostgreSQL databases.
54-
55-
When Bytebase executes schema migration on PostgreSQL databases, it will not use the configured user
56-
in the instance to execute. Instead, it uses [`SET LOCAL ROLE`](https://github.com/bytebase/bytebase/blob/b79d79d81279a29ab6e9f147632f5a2631755299/backend/plugin/db/pg/pg.go#L340-L341) to switch to the
57-
targeting PostgreSQL database owner.
58-
59-
Bytebase does this because if you are creating a table, it's likely you want the created table
60-
owner to be the database owner specific to the database instead of that shared Bytebase user.
47+
This could happen if you turn on [Postgres database tenant mode](/docs/change-database/issue/#postgres-database-tenant-mode).
6148

62-
However, for some sophisticated setup where database owner and table owner are different, this causes problem.
49+
For some sophisticated setup where database owner and table owner are different, this causes problem.
6350
Because only table owner can alter that table schema, and if the database owner is not a member of
6451
the table owner, then the execution will throw the `ERROR: must be owner of table xxx` error.
6552

25.5 KB
Loading

0 commit comments

Comments
 (0)