During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/p.gauthamprasad/Downloads/pb/pbapp/manage.py", line 22, in <module>
main()
File "/Users/p.gauthamprasad/Downloads/pb/pbapp/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/Users/p.gauthamprasad/Downloads/pb/pbvenv/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/Users/p.gauthamprasad/Downloads/pb/pbvenv/lib/python3.10/site-packages/django/core/management/__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/p.gauthamprasad/Downloads/pb/pbvenv/lib/python3.10/site-packages/django/core/management/base.py", line 402, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/p.gauthamprasad/Downloads/pb/pbvenv/lib/python3.10/site-packages/django/core/management/base.py", line 448, in execute
output = self.handle(*args, **options)
File "/Users/p.gauthamprasad/Downloads/pb/pbvenv/lib/python3.10/site-packages/django/core/management/base.py", line 96, in wrapped
res = handle_func(*args, **kwargs)
File "/Users/p.gauthamprasad/Downloads/pb/pbvenv/lib/python3.10/site-packages/django/core/management/commands/migrate.py", line 349, in handle
post_migrate_state = executor.migrate(
File "/Users/p.gauthamprasad/Downloads/pb/pbvenv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 107, in migrate
self.recorder.ensure_schema()
File "/Users/p.gauthamprasad/Downloads/pb/pbvenv/lib/python3.10/site-packages/django/db/migrations/recorder.py", line 72, in ensure_schema
raise MigrationSchemaMissing(
django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table (permission denied for schema public
LINE 1: CREATE TABLE "django_migrations" ("id" bigint NOT NULL PRIMA...
^
)
I have tried this "command python3 manage.py migrate" after creating database and linking in settings.py in this way...:-
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': '<name>',
'USER': '<username>',
'PASSWORD': 'admin',
'HOST': 'localhost',
'PORT': '5432',
}
}
i have tried grant "commands" in psql there is no use
Applying the following command solves it for me without giving the new user all privileges, just setting him as the owner of the project db.
ALTER DATABASE <db_name> OWNER TO <db_user>;
I faced the exact issue several times and solved by providing permission every single time. Anyone who stumbled in same scenario can try below command in psql CLI:
GRANT postgres TO <user>;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With