Closed shubhanshusingh closed 1 year ago
@nodece @Zxilly @Shivansh-yadav13
?? any update on this
@imp2002 @terry-xuan-gao plz take a look
Hi @shubhanshusingh, sorry for taking so long to respond to you.
Could you show me the full content of pgOptions1
, pgOptions2
and pgOptions3
?
This will help me figure out this issue : )
pgOptions1
{
database: data.database,
schema: "tenant1"
host: data.host,
port: data.port,
username: data.username,
dialect: 'postgres',
type: 'postgres',
password: data.password,
dialectOptions: {
ssl: {
rejectUnauthorized: false,
ca: data.DB_CA,
key: data.DB_TLS_KEY,
cert: data.DB_TLS_CERT,
}
}
}
pgOptions2
{
database: data.database,
schema: "tenant2"
host: data.host,
port: data.port,
username: data.username,
dialect: 'postgres',
type: 'postgres',
password: data.password,
dialectOptions: {
ssl: {
rejectUnauthorized: false,
ca: data.DB_CA,
key: data.DB_TLS_KEY,
cert: data.DB_TLS_CERT,
}
}
}
pgOptions3
{
database: data.database,
schema: "tenant3"
host: data.host,
port: data.port,
username: data.username,
dialect: 'postgres',
type: 'postgres',
password: data.password,
dialectOptions: {
ssl: {
rejectUnauthorized: false,
ca: data.DB_CA,
key: data.DB_TLS_KEY,
cert: data.DB_TLS_CERT,
}
}
}
the distinction between pgOptions is the name of the schema.
@terry-xuan-gao can we check now?
It seems like if I try to create an adapter instance, the last one overrides all previously created. For my application, I have multiple tenants and per tenant Postgres schema is different.
example:
pgOptions3 has schema name as tenant3
const casbinAdapter1 = await SequelizeAdapter.newAdapter(pgOptions1); const casbinAdapter2 = await SequelizeAdapter.newAdapter(pgOptions2); const casbinAdapter3 = await SequelizeAdapter.newAdapter(pgOptions3);
if I init above 3 adapters then it seems like casbinAdapter1 and casbinAdapter2 instance are equivalent to casbinAdapter3. So if I use any adapter in enforcer it always points to the last db adapter instance i.e. tenant3 schema instance.