Call_command makemigrations not working on EBS

I have a scenario where I need to dynamically create a table. To dynamically create the table, I wrote code to create the model.py file with the contents of the table I want to create.

As soon as this file is created, I want to execute the makemigrations command from the code itself, for example

 from django.core.management import call_command
 call_command('makemigrations')
 call_command('migrate')

it works fine in my local as well as in the AWS EC2 instance, but it doesn't work in Elastic Beanstalk (eb). and when I try to run the makemigrations command manually from eb ssh, then it gives me the following error.

PermissionError: [Errno 13] Permission denied: '/opt/python/bundle/47/app/quotations/migrations/0036_dynamic_table.py'

Does anyone know how I can handle this situation.

Another thing is that when creating new dynamic models So, how can I push this code to git, since with a new deployment EBS will replace the existing code with new code, so in this way I will lose the files that I created in EBS using these teams

thanks

+6
source share
2 answers

I agree with Eddie that you need to change the permissions of the migration folder.

The migration folder is located at: /opt/python/current/app/quotations/migrations/

You probably need to do something like:

subprocess.call(['chmod', '-R', '+w', '/opt/python/current/app/quotations/migrations/'])

You will probably need this before and / or after the makemigrations call.

Please comment if you have additional problems.

+1
source

, , EBS. ls -al /opt/python/bundle/47/app/quotations/migrations/ , 0036_dynamic_table.py. , , , , , , .

, , , , , . .

+1

All Articles