I've used this as either a either PowerShell or Bash script when in a development environment. You'll need the postgres user's password. The .sql file is the file I keep in order to be able to generate the structure of my database (and seed it) in an empty database.
It connects as the postgres user to the postgres database, drops the specified database, if it exists, creates the new database, connects to the new database, and executes the schema & seed SQL file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| psql --username=postgres --dbname=postgres --command='DROP DATABASE IF EXISTS DATABASE_NAME;' --command='CREATE DATABASE DATABASE_NAME;' --command='\c DATABASE_NAME' --command='\i create_schema_and_seed.sql' |