PostgreSQL 9.1 के साथ नई विधि
नीचे RK की सलाह के लिए धन्यवाद, मैंने इस ट्यूटोरियल पर एक नज़र डाली और पाया कि PostgreSQL 9.1 के लिए आपको केवल pgAdmin संदर्भ मेनू का उपयोग करके एक्सटेंशन postgisऔर postgis_topologyमौजूदा डेटाबेस में जोड़ना होगा । पोस्टगिस टेम्प्लेट बनाने के लिए, मैंने एक नया डेटाबेस बनाया template-postgisऔर फिर इन एक्सटेंशनों को जोड़ा। फिर मैंने इस टेम्पलेट का उपयोग करके अपना अन्य डेटाबेस बनाया। उपयोग करते समय pg_dumpमैंने पाया कि निर्यात का आकार बहुत छोटा था, क्योंकि यह सिर्फ इन पंक्तियों को शामिल करता है और विस्तार कार्यों को डंप नहीं करता है:
CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public;
CREATE EXTENSION IF NOT EXISTS postgis_topology WITH SCHEMA topology;
पुराना निरर्थक तरीका:
मैंने यहाँ .sql फ़ाइलों का उपयोग कर समाप्त किया:
/Applications/Postgres.app/Contents/MacOS/share/contrib/postgis-2.0/postgis.sql
/Applications/Postgres.app/Contents/MacOS/share/contrib/postgis-2.0/spatial_ref_sys.sql
/Applications/Postgres.app/Contents/MacOS/share/contrib/postgis-2.0/topology.sql
जब मुझे इस टेम्पलेट से बने नए डेटाबेस में मौजूदा PostGIS डेटाबेस आयात किया गया, तब भी मुझे यह त्रुटि मिली:
ERROR: type "spheroid" already exists
इसलिए मैंने यहां निर्देशों का पालन किया और ON_ERROR_ROLLBACK=on"template_postgis" नामक एक रिक्त डेटाबेस बनाने के बाद, टेम्पलेट सेट किया।
psql -U postgres -d template_postgis -1 -f /Applications/Postgres.app/Contents/MacOS/share/contrib/postgis-2.0/postgis.sql -v ON_ERROR_ROLLBACK=on
psql -U postgres -d template_postgis -1 -f /Applications/Postgres.app/Contents/MacOS/share/contrib/postgis-2.0/spatial_ref_sys.sql -v ON_ERROR_ROLLBACK=on
psql -U postgres -d template_postgis -1 -f /Applications/Postgres.app/Contents/MacOS/share/contrib/postgis-2.0/topology.sql -v ON_ERROR_ROLLBACK=on
और फिर मेरा बैकअप db आयात किया, उदा:
psql -U someuser -d somedb -1 -f somefile.sql -v ON_ERROR_ROLLBACK=on
यहां तक कि पुरानी विधि:
इसे मैने किया है:
createdb -E UTF8 -T template0 template_postgis
createlang -d template_postgis plpgsql
psql --quiet -d template_postgis -f /Applications/Postgres.app/Contents/MacOS/share/extension/postgis--2.0.1.sql
postgis--2.0.1.sqlआपके सेटअप के आधार पर रास्ता अलग होगा।