Home > Enterprise >  create schema on created database on pg-app-dev-vm
create schema on created database on pg-app-dev-vm

Time:06-24

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

CodePudding user response:

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.

  • Related