A
A
Andrei1penguin12020-11-16 00:20:44
PostgreSQL
Andrei1penguin1, 2020-11-16 00:20:44

Why are models not being added to postgresql from django?

Good day, there is postgresql, there are models, about 7, created initially and, therefore, displayed in the database.
When you try to add models, register makemigrations and migrate, no errors come out
. The migrations/0001_initial file itself ... Contains seemingly correct data, that is, the added models are there.
But they are not saved in the database, and the database, in principle, does not see migrations, except for the first ones, that is, it is impossible to delete data or add data.
What could be the reason?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2020-11-16
@fox_12

And so I delete old migrations, make new ones, makemigrations, and apply migrate

Uh-huh - only information about migrations remains in the database, and it does not know anything about the fact that you manually entered migrations into already applied migrations.
You don't have to do that.
If you want to delete something in migrations, or change, and you are SURE of your actions - first roll back to an earlier version of the migration:
migrate <app_label> <migration_name>
And then edit the migration files, with later versions. Just notify everyone working on the same project to do the same operation on their local bases.
In your case, the help of a more qualified specialist is already required most quickly, who could correct the situation, or - in your case, it will probably be easier to demolish the base and refill it, and not do it again.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question