I am using Django Framework in Python with MySQL Database
For adding a table in the database, I create a class in models.py and then run
python manage.py makemigrations. This creates the migration file in my app with the table columns details.
Now, similarly, I want to create a new function in my database.
For now, I create a new empty migration file in my app using
python manage.py makemigrations --empty myApp
and then add the SQL code to the migration file
operations[
migrations.RunSQL('Create function SQL Code')
]
This editing migration file can be done on a local or testing environment but is not advisable in the production environment. Is there any better way to create the MySQL function through Django Migrations command or models.py that works similarly to tables and creates functions only 1 time when we use the migrate command?