Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django migrate and makemigrate automatic yes on prompt

Is there a way to automatically specify YES as the default option on

manage.py makemigrations myAPp and
manage.py migrate commands

i tried the --noinput option on migrate but i think it defaults to NO not YES

like image 614
Dhanushka Amarakoon Avatar asked Oct 12 '16 05:10

Dhanushka Amarakoon


People also ask

What is difference between migrate and Makemigrations in Django?

makemigrations is responsible for packaging up your model changes into individual migration files - analogous to commits - and migrate is responsible for applying those to your database.

What task do migrations automate Django?

Migrations are one of the great features that come out of the box with Django. It automates the process of changing database after modifications in the models. With few simple commands, model changes will reflect in the database. For example, In a model named Image, we add a new field called file_size.

How do I fix migration issues in Django?

If dropping your database is not an option then the next best solution is to find the last working state of the database and then create new migration files. Find the last good state where your database was working. Delete all the files from the migrations folder. Uncomment the changes which you did in step 2.


1 Answers

found the answer on another question

You can use the 'yes' command which passes a 'y' to all questions

yes | python manage.py makemigrations myApp

if you want to edit the response (i.e send a 'yes' instead of 'y') you can add it as a parameter

yes yes | python manage.py migrate
like image 118
Dhanushka Amarakoon Avatar answered Oct 12 '22 03:10

Dhanushka Amarakoon