Creating the testing db fails (django 1.8.5)

58 views
Skip to first unread message

Uwe Schuerkamp

unread,
Oct 14, 2015, 12:34:05 PM10/14/15
to Django users
Hi folks,

this is my first posting in this group, so I'm sorry in advance if I'm breaking any rules or missing some vital information.

My setup: 

Ubuntu Server 14.04.x
Python 2.7.6
Django 1.8.4 (updated to 1.8.5 recently) installed via "pip"
MariaDB 5.5.44

I'm trying to set up a test framework for a little internal project which I've been working on since the Django 1.3 days. I've recently migrated the project to Django 1.8.4/5 via Django 1.7, and everything appears to be working fine. 

Trying to set up a testing framework for the first time to get out of my bad "non-testing" habit and increase the test coverage above "0%" for the first time ever, I've run into a problem when the manage.py script tries to create the test database (permissions on the MySQL side are ok, i've tested createdb, dropping, creating and changing tables in the test db manually): 


I've been googling for quite some time and have tried creating the migrations via "--fake-initial", but nothing has helped to work around the problem. 

I've read it could be some foreign key problem (MariaDB 5.5.x backend), but I'm at a loss on how to analyze things further except for randomly reordering my models which seems a bit silly. 8( 

Thanks in advance for any pointers, 

Uwe

Mike Dewhirst

unread,
Oct 15, 2015, 6:59:23 AM10/15/15
to django...@googlegroups.com
On 14/10/2015 11:34 PM, Uwe Schuerkamp wrote:
> Hi folks,
>
> this is my first posting in this group, so I'm sorry in advance if I'm
> breaking any rules or missing some vital information.
>
> My setup:Â
>
> Ubuntu Server 14.04.x
> Python 2.7.6
> Django 1.8.4 (updated to 1.8.5 recently) installed via "pip"
> MariaDB 5.5.44
>
> I'm trying to set up a test framework for a little internal project
> which I've been working on since the Django 1.3 days. I've recently
> migrated the project to Django 1.8.4/5 via Django 1.7, and everything
> appears to be working fine.Â
>
> Trying to set up a testing framework for the first time to get out of my
> bad "non-testing" habit and increase the test coverage above "0%" for
> the first time ever, I've run into a problem when the manage.py script
> tries to create the test database (permissions on the MySQL side are ok,
> i've tested createdb, dropping, creating and changing tables in the test
> db manually):Â
>
> http://pastebin.com/XDRiqaqL

A quick glance at pastebin indicates the error is a failure to delete
the test database.

Can you manually delete it prior to running the tests? That would skip
the entire section (apparently) which raises the error.

Mike

>
> I've been googling for quite some time and have tried creating the
> migrations via "--fake-initial", but nothing has helped to work around
> the problem.Â
>
> I've read it could be some foreign key problem (MariaDB 5.5.x backend),
> but I'm at a loss on how to analyze things further except for randomly
> reordering my models which seems a bit silly. 8(Â
>
> Thanks in advance for any pointers,Â
>
> Uwe
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/6d0a3eee-fa06-4ba4-b8ac-5447c073e830%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/6d0a3eee-fa06-4ba4-b8ac-5447c073e830%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Uwe Schuerkamp

unread,
Oct 15, 2015, 8:09:39 AM10/15/15
to Django users
Hi Mike,

thanks for your quick reply.

I tried deleting the test database, but that didn't help either (actually I tried this several times before I posted here, I even set up a "fresh" production database  on my test machine and re-imported the live data in order to solve the problem).

All the best, 

Uwe

Uwe Schuerkamp

unread,
Oct 15, 2015, 8:15:12 AM10/15/15
to Django users
Here's some more info in case it helps: 

The "manage.py test" call seems to get as far as creating the table "django_migrations", then things break. The production DB has several more tables (25 in all) I'm not seeing in the output below, so I guess this issue must be related to the migrations table in some manner. 

All the best, Uwe

############################################################
MariaDB [test_club300_owl]> show tables ; 
+-----------------------------------------+
| Tables_in_test_club300_owl              |
+-----------------------------------------+
| club300_alert                           |
| club300_area                            |
| club300_bird                            |
| club300_birdcategory                    |
| club300_birdcategory_birdcategory_birds |
| club300_country                         |
| club300_location                        |
| club300_newsitem                        |
| club300_observation                     |
| club300_toplist                         |
| club300_toplist_toplist_birds           |
| club300_userprofile                     |
| django_migrations                       |
+-----------------------------------------+
13 rows in set (0.00 sec)




Uwe Schuerkamp

unread,
Oct 15, 2015, 9:25:52 AM10/15/15
to Django users
I solved it myself... looks like I forgot to create the initial migrations for the app. After running

python manage.py makemigrations club300
python  manage.py migrate --fake-initial

python manage.py test club300

appears to work fine. Sorry for the noise & thanks for your help!

Uwe

Reply all
Reply to author
Forward
0 new messages