[英]PG::UndefinedFile: ERROR: could not open extension control file
升级 Postgres 后,当我尝试迁移数据库时出现以下错误。
enable_extension(:postgis)
SQL (17.2ms) CREATE EXTENSION IF NOT EXISTS "postgis"
PG::UndefinedFile: ERROR: could not open extension control file "/usr/local/Cellar/postgresql/9.4.5/share/postgresql/extension/postgis.control": No such file or directory
: CREATE EXTENSION IF NOT EXISTS "postgis"
(0.3ms) ROLLBACK
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::UndefinedFile: ERROR: could not open extension control file "/usr/local/Cellar/postgresql/9.4.5/share/postgresql/extension/postgis.control": No such file or directory
: CREATE EXTENSION IF NOT EXISTS "postgis"/Users/harshamv/Sites/clink/db/migrate/20150812164615_enable_postgis.rb:3:in `change'
-e:1:in `<main>'
ActiveRecord::StatementInvalid: PG::UndefinedFile: ERROR: could not open extension control file "/usr/local/Cellar/postgresql/9.4.5/share/postgresql/extension/postgis.control": No such file or directory
: CREATE EXTENSION IF NOT EXISTS "postgis"
/Users/harshamv/Sites/clink/db/migrate/20150812164615_enable_postgis.rb:3:in `change'
-e:1:in `<main>'
PG::UndefinedFile: ERROR: could not open extension control file "/usr/local/Cellar/postgresql/9.4.5/share/postgresql/extension/postgis.control": No such file or directory
/Users/harshamv/Sites/clink/db/migrate/20150812164615_enable_postgis.rb:3:in `change'
-e:1:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
不知道从哪里开始。 大多数其他问题似乎与 Linux 有关,当我尝试创建符号链接时它也不起作用。
你应该安装 postgresql-9.4-postgis-2.1
对于 MacOS,使用以下命令安装 postgis 对我有用:
brew install postgis
对于 Ubuntu,以下命令有效:
sudo apt install postgresql-10-postgis-scripts
检测可用的 postgresql postgis 版本
sudo apt-cache search postgis
安装
sudo apt install postgresql-12-postgis-3-scripts
切换 postgres 用户
sudo -i -u postgres
创建一个数据库,然后连接它。 在此之后运行 postgis 扩展激活命令
CREATE EXTENSION postgis;
稍后您可以通过以下方式检查并验证它
SELECT PostGIS_version();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.