0

I'm trying to run some tests for a Django project and to do this Django creates a new database specific for running the tests.

In my case the main database is named 'kim' and Django creates a database 'test_kim' to run the tests on.

Since I have a CICharField in one of my models, I have to run this command after the database is created and before Django migrations run.

psql =# \c db_1
CREATE EXTENSION citext;

Now I'm wondering how I can run this command for the test database?

1
  • Adding a custom migration can be an option, i guess for this case. Commented Jan 18, 2019 at 18:14

1 Answer 1

2

You should create a migration that handles creating the extension for you. Here are the docs on it.

You would do:

python manage.py makemigrations <APP_NAME> --empty

Then in that migration import:

from django.contrib.postgres.operations import CITextExtension

and add CITextExtension() it to the migrations list. This migration should be a dependency of the migration that created the CITextField field.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.