12.07.2015 Views

PostGIS 1.5.8 Manual - Fedora Project Packages GIT repositories

PostGIS 1.5.8 Manual - Fedora Project Packages GIT repositories

PostGIS 1.5.8 Manual - Fedora Project Packages GIT repositories

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>PostGIS</strong> <strong>1.5.8</strong> <strong>Manual</strong>9 / 3102.6 Create a spatially-enabled database from a templateSome packaged distributions of <strong>PostGIS</strong> (in particular the Win32 installers for <strong>PostGIS</strong> >= 1.1.5) load the <strong>PostGIS</strong> functionsinto a template database called template_postgis. If the template_postgis database exists in your PostgreSQLinstallation then it is possible for users and/or applications to create spatially-enabled databases using a single command. Notethat in both cases, the database user must have been granted the privilege to create new databases.From the shell:# createdb -T template_postgis my_spatial_dbFrom SQL:postgres=# CREATE DATABASE my_spatial_db TEMPLATE=template_postgis2.7 UpgradingUpgrading existing spatial databases can be tricky as it requires replacement or introduction of new <strong>PostGIS</strong> object definitions.Unfortunately not all definitions can be easily replaced in a live database, so sometimes your best bet is a dump/reload process.<strong>PostGIS</strong> provides a SOFT UPGRADE procedure for minor or bugfix releases, and an HARD UPGRADE procedure for majorreleases.Before attempting to upgrade postgis, it is always worth to backup your data. If you use the -Fc flag to pg_dump you will alwaysbe able to restore the dump with an HARD UPGRADE.2.7.1 Soft upgradeAfter compiling you should find several postgis_upgrade*.sql files. Install the one for your version of <strong>PostGIS</strong>. Forexample postgis_upgrade_13_to_15.sql should be used if you are upgrading from postgis 1.3 to 1.5.$ psql -f postgis_upgrade_13_to_15.sql -d your_spatial_databaseIf a soft upgrade is not possible the script will abort and you will be warned about HARD UPGRADE being required, so do nothesitate to try a soft upgrade first.NoteIf you can’t find the postgis_upgrade*.sql files you are probably using a version prior to 1.1 and must generatethat file by yourself. This is done with the following command:$ utils/postgis_proc_upgrade.pl postgis.sql > postgis_upgrade.sql2.7.2 Hard upgradeBy HARD UPGRADE we intend full dump/reload of postgis-enabled databases. You need an HARD UPGRADE when postgisobjects’ internal storage changes or when SOFT UPGRADE is not possible. The Release Notes appendix reports for each versionwhether you need a dump/reload (HARD UPGRADE) to upgrade.<strong>PostGIS</strong> provides an utility script to restore a dump produced with the pg_dump -Fc command. It is experimental so redirectingits output to a file will help in case of problems. The procedure is as follow:Create a "custom-format" dump of the database you want to upgrade (let’s call it "olddb")$ pg_dump -Fc olddb > olddb.dump

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!