在搜索时,我已阅读其他帖子,回答了这个问题.
我正在使用PostgreSQL 9.1,并使用创建扩展'citext' CREATE EXTENSION citext,但是当我尝试创建任何类型'citext'的列时,它会抛出此错误
错误:类型"citext"不存在
我研究过但没有找到具体的答案?知道为什么吗?
Nul*_*ion 80
好想通了.我有几个数据库,CREATE EXTENSION citext必须为每个数据库运行以在该数据库中安装扩展.你必须在psql提示符上做:
psql =# \c db_1
CREATE EXTENSION citext;
psql =# \c db_2
CREATE EXTENSION citext;
Run Code Online (Sandbox Code Playgroud)
希望它能帮助别人.谢谢.
sha*_*unc 16
@NullException是正确的,需要在每个数据库中创建扩展.如果要自动创建扩展,可以在template1数据库中创建它(默认情况下,至少)是用作"create database"模型的数据库,因此在psql中具有适当的权限:
\c template1
create extension citext;
Run Code Online (Sandbox Code Playgroud)
然后,新数据库默认包含citext.
Ily*_*hov 11
要使用citext,请在第一次迁移操作之前使用该CITextExtension操作citext在 PostgreSQL 中设置扩展CreateModel。
https://docs.djangoproject.com/en/2.2/ref/contrib/postgres/fields/#citext-fields
from django.contrib.postgres.operations import CITextExtension
class Migration(migrations.Migration):
...
operations = [
CITextExtension(),
...
]
Run Code Online (Sandbox Code Playgroud)
同样HStoreField作为
https://docs.djangoproject.com/en/2.2/ref/contrib/postgres/operations/#create-postgresql-extensions
| 归档时间: |
|
| 查看次数: |
20027 次 |
| 最近记录: |