2013-02-19 102 views
16

पर व्याख्यान स्थापित करना मैंने PostgreSQL में व्याख्या स्थापित करने के लिए एक नया डेटाबेस स्थापित किया है। जब मैं रेक डीबी चलाता हूं: माइग्रेट करता है, यह अधिकांश टेबल बनाता है, लेकिन फिर यह विफल रहता है:उबंटू 12.04 एलटीएस

-- execute("INSERT INTO archetypes (name_key, created_at, updated_at) VALUES ('poll', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)") 
    -> 0.0009s 
-- add_column(:forum_threads, :archetype_id, :integer, {:default=>1, :null=>false}) 
    -> 0.0209s 
== CreateArchetypes: migrated (0.0424s) ====================================== 

== AddMetaDataToForumThreads: migrating ====================================== 
-- execute("CREATE EXTENSION IF NOT EXISTS hstore") 
rake aborted! 
An error has occurred, this and all later migrations canceled: 

PG::Error: ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/hstore.control": No such file or directory 
: CREATE EXTENSION IF NOT EXISTS hstore 
/usr/local/rvm/gems/ruby-1.9.3-p385/bundler/gems/MiniProfiler-d149f34fcdb6/Ruby/lib/patches/sql_patches.rb:155:in `exec' 
/usr/local/rvm/gems/ruby-1.9.3-p385/bundler/gems/MiniProfiler-d149f34fcdb6/Ruby/lib/patches/sql_patches.rb:155:in `async_exec' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activerecord-3.2.12/lib/active_record/connection_adapters/postgresql_adapter.rb:652:in `block in execute' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activesupport-3.2.12/lib/active_support/notifications/instrumenter.rb:20:in `instrument' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activerecord-3.2.12/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `execute' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activerecord-3.2.12/lib/active_record/migration.rb:466:in `block in method_missing' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activerecord-3.2.12/lib/active_record/migration.rb:438:in `block in say_with_time' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activerecord-3.2.12/lib/active_record/migration.rb:438:in `say_with_time' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activerecord-3.2.12/lib/active_record/migration.rb:458:in `method_missing' 
/root/discourse/db/migrate/20120921162512_add_meta_data_to_forum_threads.rb:3:in `change' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activerecord-3.2.12/lib/active_record/migration.rb:407:in `block (2 levels) in migrate' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activerecord-3.2.12/lib/active_record/migration.rb:407:in `block in migrate' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in `with_connection' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activerecord-3.2.12/lib/active_record/migration.rb:389:in `migrate' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activerecord-3.2.12/lib/active_record/migration.rb:528:in `migrate' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activerecord-3.2.12/lib/active_record/migration.rb:720:in `block (2 levels) in migrate' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activerecord-3.2.12/lib/active_record/migration.rb:775:in `call' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activerecord-3.2.12/lib/active_record/migration.rb:775:in `block in ddl_transaction' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activerecord-3.2.12/lib/active_record/transactions.rb:208:in `transaction' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activerecord-3.2.12/lib/active_record/migration.rb:775:in `ddl_transaction' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activerecord-3.2.12/lib/active_record/migration.rb:719:in `block in migrate' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activerecord-3.2.12/lib/active_record/migration.rb:700:in `each' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activerecord-3.2.12/lib/active_record/migration.rb:700:in `migrate' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activerecord-3.2.12/lib/active_record/migration.rb:570:in `up' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activerecord-3.2.12/lib/active_record/migration.rb:551:in `migrate' 
/usr/local/rvm/gems/ruby-1.9.3-p385/gems/activerecord-3.2.12/lib/active_record/railties/databases.rake:179:in `block (2 levels) in <top (required)>' 
/usr/local/rvm/gems/ruby-1.9.3-p385/bin/ruby_noexec_wrapper:14:in `eval' 
/usr/local/rvm/gems/ruby-1.9.3-p385/bin/ruby_noexec_wrapper:14:in `<main>' 
Tasks: TOP => db:migrate 

कोई सुराग?

उत्तर

45

यह CREATE EXTENSION [...] hstore पर प्रयास करते समय डेटाबेस त्रुटि "एक्सटेंशन नियंत्रण फ़ाइल नहीं खोल सका" डेटाबेस से प्रकट होता है कि एक्सटेंशन hstore स्थापित नहीं है।

उबंटू पर, आप postgresql-contrib पैकेज स्थापित करके एक्सटेंशन इंस्टॉल कर सकते हैं।

sudo apt-get install postgresql-contrib 

उपयोगकर्ता टेरीज्रे ने एक गिस्ट में enabling hstore दस्तावेज किया है।

+0

मैं कर रहा हूँ, हालांकि, एक sudoer, और मैं इसे स्थापित करने में सक्षम होना चाहिए। –

+0

मैं यह भी जोड़ सकता हूं कि मैंने इसे रूट और डीबी उपयोगकर्ता के रूप में चलाया। टिप्पणी स्पैम के लिए खेद है। –

+0

अपने डेटाबेस पर अपनी उपयोगकर्ता भूमिका की जांच करें। मुझे लगता है कि आप एक सुपरसुर डीबी-उपयोगकर्ता-वार नहीं हैं। [उबंटू पीजी गाइड] (https://help.ubuntu.com/community/PostgreSQL) आपकी डीबी-उपयोगकर्ता भूमिकाओं को स्थापित करने में मदद के लिए उपयोगी हो सकता है। –

2

आप इस तरह के 9.1 और 9.3

के रूप में अपने ubuntu पर दो Postgresql स्थापना है, तो संस्करण विशिष्ट स्थापना चलाने से पहले, आप अपने instructions जो मैं मामले में नीचे टीका कर रहा हूँ का उपयोग कर रेपो सही postgres जोड़ने पड़ सकते हैं वे गायब हो जाते हैं:

deb http://apt.postgresql.org/pub/repos/apt/ UBUNTU_VERSION_NAME-pgdg main 
sudo apt-get install wget ca-certificates 
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - 
apt-get update 

(UBUNTU_VERSION_NAME भरोसेमंद द्वारा प्रतिस्थापित किया जाना चाहिए या जो कुछ भी अपने संस्करण का नाम है)

तो आप अलग से प्रत्येक सर्वर पर hstore विस्तार स्थापित करने के लिए नीचे आदेशों का उपयोग कर सकते हैं:

Postgresql 9.1:

sudo apt-get install postgresql-contrib-9.1 

Postgresql 9.3:

sudo apt-get install postgresql-contrib