WSO2 Identity Server PostgreSQL Database Schema - postgresql

Can I change PostgreSQL database schema in WSO2 IS? For default, it is public, but I want to change it to my custom one.
Please, help.
EXPLANATION:
I connected PostgreSQL database as primary database into WSO2 IS. First run wso2server.bat with -Dsetup parameter and all database tables was created in public schema of connected database.
I hope, that I can change default public schema to my own, for example wso2.

Yes it's possible. You have to modify the db scripts to use the custom schema with following line at the scripts.
SET search_path TO wso2;
Then set the search_path to include the schema you are using.
Refer the post here for more detailed steps.

Related

create schema on created database on pg-app-dev-vm

I've cloned this Github repository PostgreSQL VM via Vagrant. Been trying to create a new schema test but it always ends up under postgres database. Considering the create database is named myapp, how can I create the test schema under myapp database?
I've been trying to add this script under the Vagrant-setup/bootstrap.sh.
cat << EOF | su - postgres -c psql myapp
create schema test;
EOF
As a reference it may help to check your connection string in order to ensure you are connected to the right database. The official postgresql documentation is quite helpful here:
https://www.postgresql.org/docs/current/libpq-connect.html
This may help as well for understanding the format:
What is the format for the PostgreSQL connection string / URL?
Outside of that you will have to ensure permissions are set appropriately for the user to create schemas in the database and to configure the search_path for easy access to objects under the schema.

prisma db pull doesn't see a new table

I have existing schema for prisma.
I copied the table from another schema to be included in the Prisma schema.
But when I run prisma db pull new table doesn't appear in Prisma schema.
Why?
If you use supabase and running this command and it returns something like this 'The following models were commented out because we couldn't retrieve columns for them. Please check your privileges.' or something similar regarding privileges, the solution is to go to your SQL editor from supabase and put this command and execute it
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO postgres;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO postgres;
You're misinterpreting the function of the prisma db pull command.
From the docs
The db pull command connects to your database and adds Prisma models to your Prisma schema that reflect the current database schema.
Basically, it will make your Prisma schema match the existing database schema. What you want is the opposite here: Update the database schema to match the current Prisma schema.
You can do this in two ways:
If you want to update the database and keep the changes in your migration history, use the prisma migrate dev command. More Info
If you just want to update the database without creating a migration, use the prisma db push command. More info
More information is available in the docs explaining how you should choose between 1 and 2.
I had a similar issue once and a quick check confirmed for me that it was the lack of security permissions granted for prisma on new table in the database itself.
Try this:
Note the name of the database user that Prisma connects to the database with. You'll likely find this via your schema.prisma file, or perhaps via a DATABASE_URL config setting in the related .env file if you're using that with prisma.
Go into the database itself and ensure that database user which Prisma connects with has been granted sufficient security privileges to that new table. (note: what 'sufficient' is I cannot say since it depends on your own needs. At a guess, I'd say at least 'select' permission would be needed.)
Once you've ensure that user has sufficient privileges, try running a prisma db pull command once again.
For reference, another thing you could do is:
cross-check against one of the other tables that is already in your database that works correctly with prisma.
compare the security privileges of that old table with the security privileges of the new table and see if there are any differences.

Postgres for Airflow backend DB to create metadata tables in a specified schema

I'm setting up postgres backend for Airflow metadata DB using the following sqlalchemy connection string:
sql_alchemy_conn = postgresql+psycopg2://<user>:<pass>#<host>:5432/<db>
When I run initdb/upgradedb, the tables are created in public schema.
Is there a way to create the tables in a specified schema?
Can the schema where I would like the tables to be created be specified as part of the connection string?
From the docs:
Also note that since SqlAlchemy does not expose a way to target a specific schema in the Postgres connection URI, you may want to set a default schema for your role with a command similar to ALTER ROLE username SET search_path = airflow, foobar;
So, connect to postgres, and set the search path for your user.

Can't create new schema in an OVH postgres

I have a PostgreSQL server on OVH's Cloud DB and have been using its databases for my web apps.
So far so good.
I got a project where It's a requirement to have schemas. Strangely enough, I am unable to create schemas on the user with "Administrator" privileges.
I have prepared scripts using schemas, so I just need to run them on a prepared database but I need a database with schemas to run them.
Here is my process:
Create a new database
Select option "Create user"
Select option for privilages: "Administrator"
Commit configuration
Wait for database creation
Connect to database with the new config via PGAdmin
Run command create schema if not exists "vMobile";
Recieve following error:
ERROR: permission denied for database my-database-dev
SQL state: 42501
I created a ticket for this but the wait is taking too long.
Support answer
Ok, so I got a response from the OVH support and there is no option for the user to create new schemas as their CloudDB enables access only to schema public and mentioned privileges Administrator, Read/Write, Read, None are only applicable to the public schema.
Workaround
My solution to this is to create tables with schema name included in their names
like so:
Desired outcome: "vCommon"."Route"
Workaround: "public"."vCommon_Route"

symmetricsDS and postgresql

I wan't to replicate two databases with symmetricDS,
First, i try to do this tutorial https://www.symmetricds.org/doc/3.8/html/tutorials.html
i have install symmetricDs I have installed symmetricDS on my postgresql serveur.
and execute this commands :
../bin/dbimport --engine corp-000 --format XML --alter-case create_sample.xml
../bin/symadmin --engine corp-000 create-sym-tables
../bin/dbimport --engine corp-000 insert_sample.sql
bin/sym
But No tables was write in my database, and no symmetric table too
Can't you help ?
Verify that the user account provided to connect your SymmetricDS nodes has the ability to create tables. Then I would check the symmetric.log for any obvious errors. By default it would create the tables in the default schema of the user account provided so be sure to check that schema for the tables.