Conteúdo do Curso
Django ORM Ninja: Advanced Techniques for Developers
Django ORM Ninja: Advanced Techniques for Developers
Migrations
What are migrations? Migrations are looking for changes in the schema of the database. A schema is a set of tables. Django ORM uses the 'Code First' approach, meaning we first change the code, and then migrations help update the database state to match the code. Currently, we don't have a database set up; we only have the code for our models.
Let's start with this command:
Here, db is the application for which we are creating migrations. Now, we have two new files: the db.sqlite3 file and 0001_initial.py in the migrations folder. The db.sqlite3 file is not yet functional.
Executing python manage.py migrate will complete all operations written in the 0001_initial.py file. After running this command, we should see various messages indicating the progress.
Obrigado pelo seu feedback!