-- Installing PostGIS
CREATE DATABASE gisdb;
-- if in psql
\c gisdb
ALTER DATABASE gisdb SET search_path=public,postgis,tiger,contrib;
-- if in psql
\c gisdb
CREATE SCHEMA IF NOT EXISTS postgis;
CREATE SCHEMA IF NOT EXISTS contrib;
CREATE EXTENSION postgis SCHEMA postgis; --- geometry, geography data types
-- separated in PostGIS 3.0 as separate extension
CREATE EXTENSION postgis_raster SCHEMA postgis; -- used to be part of postgis extension
CREATE EXTENSION postgis_sfcgal SCHEMA postgis; -- much of the functionality like dealing with 2d TINS and Polyhedralsurfaces now supported in PostGIS proper
CREATE EXTENSION postgis_topology;
-- used by postgis_tiger_geocoder
CREATE EXTENSION fuzzystrmatch SCHEMA contrib; -- note part of PostGIS
CREATE EXTENSION address_standardizer SCHEMA contrib; -- for standardizing addresses
CREATE EXTENSION postgis_tiger_geocoder; -- needs postgis and fuzzystrmatch, can use address_standardizer

-- How you upgrade 
SELECT postgis_extensions_upgrade();

-- Verify version of PostGIS
SELECT postgis_full_version();

/**POSTGIS="3.2.0dev 3.2.0alpha1-19-gf48c4a86a" [EXTENSION] PGSQL="140" GEOS="3.10.0dev-CAPI-1.15.0" SFCGAL="1.3.10" PROJ="7.1.1" GDAL="GDAL 3.2.3, released 2021/04/27" LIBXML="2.9.9" LIBJSON="0.12" LIBPROTOBUF="1.2.1" WAGYU="0.5.0 (Internal)" TOPOLOGY RASTER**/

CREATE SCHEMA IF NOT EXISTS foss4g2021;
CREATE SCHEMA IF NOT EXISTS staging;
-- default creation to foss4g2021 if not schema specified
SET search_path=foss4g2021,public,postgis,contrib,topology,tiger;