skaz skaz - 19 days ago 6
MySQL Question

Django 1054 - Unknown Column in field list

I have a Django project and I did the following:

  1. Added a table with some columns

  2. Insert some records into the db

  3. Added a new column that I didn't realize I needed

  4. Made an update to populate that column

When I did a
everything worked just fine. The new db column was created on the table and the values were populated.

When I try to run my tests, however, I now bomb out at step 2 above. When I do insert, I believe it is expecting that field to be there, even though it hasn't been created at that point yet.

What should I do?

EDIT: More info

I first made a class, class A and did a migration to create the table. Then I ran this against my db. Then I wrote a manual migration to populate some data that I knew would be there. I ra n this against the db. I realized sometime later that I need an extra field on the model. I added that field and did a migration and ran it against the database. Everything worked fine and I confirmed the new column is in the database.

Now, I went to run my tests. It tried to create the test db and bombed out, saying "1054 - Unknown column [my new column that I added to an existing table]" at the time when it is trying to run the populate data script that I wrote. It is likely looking at the table, noticing that the third field exists in the model, but not yet in the database, but I don't know how to do it better.


I believe this was because the migration scripts were getting called out of order, due to a problem I had setting them up. Everything is ok now.