私はdjangoアプリでpostgresを使用しており、データベースにhstore拡張機能を手動で作成しました。しかし、テストを実行すると、新しいデータベースを作成しようとし、hstore 拡張機能が見つからないと失敗します。
次のエラーが表示されます。
django.db.utils.ProgrammingError: hstore type not found in the database. please install it from your 'contrib/hstore.sql' file
この投稿に従って移行を更新しました。次のとおりです。
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.conf import settings
from django.contrib.postgres.operations import HStoreExtension
import django.contrib.postgres.fields
import django.contrib.postgres.fields.hstore
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
HStoreExtension(),
migrations.CreateModel(
name='AppUser',
fields=[
('id', models.AutoField(serialize=False, verbose_name='ID', primary_key=True, auto_created=True)),
('created_date', models.DateTimeField(auto_now_add=True)),
('modified_date', models.DateTimeField(auto_now=True)),
('lock', models.BooleanField(default=False)),
('username', models.CharField(max_length=100)),
('email', models.EmailField(max_length=150)),
('social_data', django.contrib.postgres.fields.hstore.HStoreField(blank=True, default='')),
('phone_number', models.CharField(max_length=15)),
('photo', models.URLField(blank=True)),
('gender', models.TextField(max_length=6)),
('badges', django.contrib.postgres.fields.ArrayField(size=None, base_field=models.CharField(max_length=30))),
],
options={
'abstract': False,
},
),
]