使用 Heroku 拒绝关系 django_migrations 的权限

2024-04-24

在尝试在 Heroku 上使用 django 迁移数据库更改时,我得到:

psycopg2.ProgrammingError: permission denied for relation django_migrations

其他人已经能够通过授予适当的权限来解决此问题(例如,关系许可被拒绝 https://stackoverflow.com/questions/15520361/permission-denied-for-relation)。不幸的是,我无法在 Heroku 爱好层授予权限或创建新用户。

我能够回滚一些迁移,但最终我得到了:

django.db.utils.ProgrammingError: table "labs_branch_tests" does not exist

并且无法迁移回新的迁移。


关系 django_migrations 权限被拒绝的完整回溯

  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 204, in handle
    fake_initial=fake_initial,
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/executor.py", line 115, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/executor.py", line 250, in apply_migration
    self.recorder.record_applied(migration.app_label, migration.name)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 73, in record_applied
    self.migration_qs.create(app=app, name=name)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/query.py", line 394, in create
    obj.save(force_insert=True, using=self.db)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/base.py", line 807, in save
    force_update=force_update, update_fields=update_fields)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/base.py", line 837, in save_base
    updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/base.py", line 923, in _save_table
    result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/base.py", line 962, in _do_insert
    using=using, raw=raw)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/query.py", line 1076, in _insert
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1107, in execute_sql
    cursor.execute(sql, params)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: permission denied for relation django_migrations

psycopg2.ProgrammingError 的完整回溯:表“labs_branch_tests”不存在

  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 204, in handle
    fake_initial=fake_initial,
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/executor.py", line 119, in migrate
    state = self._migrate_all_backwards(plan, full_plan, fake=fake)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/executor.py", line 194, in _migrate_all_backwards
    self.unapply_migration(states[migration], migration, fake=fake)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/executor.py", line 264, in unapply_migration
    state = migration.unapply(state, schema_editor)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/migration.py", line 178, in unapply
    operation.database_backwards(self.app_label, schema_editor, from_state, to_state)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/operations/fields.py", line 95, in database_backwards
    schema_editor.remove_field(from_model, from_model._meta.get_field(self.name))
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 457, in remove_field
    return self.delete_model(field.remote_field.through)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 324, in delete_model
    "table": self.quote_name(model._meta.db_table),
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 120, in execute
    cursor.execute(sql, params)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: table "labs_branch_tests" does not exist

我可以通过在 postgres 终端中向用户授予权限来解决这个问题。

首先通过 Heroku CLI 连接到 postgres (heroku pg:psql).

这很笨重,但可以通过调用获取您的 Heroku postgres 用户名\c在 postgres 终端中。 (最后一行输出将是You are now connected to database DATABASE_NAME as user USERNAME.)

然后按照其他人所示授予权限:

GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public to USERNAME;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public to USERNAME;
GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public to USERNAME;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 Heroku 拒绝关系 django_migrations 的权限 的相关文章

随机推荐

  • 如何使用 mediaelement.js 获取 HTML5 音频播放列表?

    我尝试在 mediaelement js 中搜索音频播放列表的示例 但我没有找到 mediaelement js 支持音频播放列表吗 如果是这样 请支持我的示例代码或链接 非常感谢 我设法获得了一个超级基本 阅读 hacky 的播放列表演示
  • WAMP服务器将MySQL切换为MariaDB

    如何在WAMP 3 1 0中将数据库从MySQL切换到MariaDB 我正在寻找它 但我找不到它 从您显示的图像来看 MySQL 和 MariaDB 似乎都已经在运行 注意 这有点占用内存 简单测试看看 MySQL 和 MariaDB 是否
  • python服务器中进程之间共享列表

    我有简单的UDP服务器 它适用于多重处理 我想创建一个列表 其中包含有关所有客户的信息 I use Manager 但我不明白 如何在列表中附加信息 我需要传输 Manager 的对象来处理 但是如何 我使用新属性的方法不起作用 impor
  • 将图像插入 JTable

    我在将图像插入 JTable 时遇到问题 我搜索了一下 发现有两种方法 您可以覆盖表模型的 getcolumnclass 或创建自定义 tablecellrender 我选择使用以下代码制作自己的单元格渲染器 public class My
  • 从 Helm stable/cert-manager 升级到 jetstack/cert-manager

    我们有一个生产 AKS 集群 其中包含stable cert manager安装 helm 图表以允许使用 Let s Encrypt 证书 当前安装的版本是cert manager v0 6 0 in the kube system命名空
  • Laravel:BadMethodCallException 方法 [find] 不存在

    当尝试使用模型对象 User 从数据库中提取一些值时 出现以下错误 BadMethodCallException Method find does not exist 这是我的文件 模范用户
  • 错误 NU5049 不支持 SDK 样式项目的 pack 命令

    我的解决方案包含 Framework 4 8 项目 Net Standard 2 1 项目和 net6 项目 它已经运行了几周 没有出现任何问题 今天构建管道开始失败并出现错误 错误 nuget 命令失败 退出代码 1 和错误 错误 NU5
  • 解析iOS SDK:从Xcode调用云函数

    Scenario我想在我的应用程序中使用这两个云函数 他们检查用户的在线状态 我想为每个用户设置一个布尔键 isOnline 如果用户在线 则设置为 是 如果用户不在线 则设置为 否 var moment require moment Pa
  • 使用 jQuery 获取类中不同类型的输入

    假设我在 JavaScript 中有一个 jquery 函数 并且到目前为止我有这段代码 效果很好 jQuery div class someClass input type text each function some code 在上面
  • 如何在 C# 中使用随机数?

    我正在用 C 和 XNA 开发 Pong 我想使用一个随机数 在一定范围内 来确定诸如球是否直线反弹或以一定角度反弹以及球击中球拍时移动的速度之类的事情 我想知道如何实施 Use the Random http msdn microsoft
  • 为什么我收到 PayPal Android Native Checkout SDK - 无效的 client_id 或 redirect_uri

    我正在使用新的 Android Native Checkout SDK 和 Kotlin 并且我一直遵循文档中的每一步 但这种情况不断发生 我不知道为什么 我也在尝试PayPal Android Native Checkout SDK 无效
  • 为什么调用指定命名空间的函数会更慢?

    我认为指定我给出的命名空间R要做的工作更少 但我可能是错的 library microbenchmark gt microbenchmark unique default c 1 1 10 base unique default c 1 1
  • 忽略 git log -p 中的文件

    我正在尝试总结我在一个项目上的工作 问题是我不想在输出中包含测试文件git log patch 这些文件位于一个名为mtest 但是 该文件夹还包含我确实想展示的测试套件代码 我想排除的测试文件具有扩展名mscx or xml 所以我希望过
  • 关闭文件夹/命名空间约定

    我看到人们在谈论烦恼Visual Studio 自动创建与项目文件夹相对应的命名空间 https stackoverflow com questions 1289425 should i stop fighting visual studi
  • 如何使用 conda 卸载 r-essentials?

    最近 我安装了r essentials using conda命令 conda install c r r essentials正如这个网址中所描述的 https anaconda org r r essentials https anac
  • Angular2 条件路由

    这可能是一个基本问题 但是在 Angular2 中是否有任何方法可以进行条件路由 或者 有人会在路由器之外这样做吗 我知道 ui router 有一定的能力做到这一点 但我在 Angular2s 路由器中没有看到类似的东西 如上所述 角路线
  • 通过值获取 std::queue 中元素的索引

    有没有一种简单的方法来获取元素在 a 中的位置std queue通过它在 C 中的值 例如 std queue
  • 重新声明第 3 方库中不正确的打字稿类型

    我正在使用带有 types winston 类型的winston 3 0 这些类型尚未完全兼容 并且我遇到了类型中的错误 我不知道如何纠正 这是我的代码 记录器 ts export function middleware express H
  • Show 的新实例声明

    我正在尝试在 Haskell 中为我创建但未成功创建的新数据类型添加实例声明 到目前为止我已经尝试过 data Prediction Prediction Int Int Int showPrediction Prediction gt S
  • 使用 Heroku 拒绝关系 django_migrations 的权限

    在尝试在 Heroku 上使用 django 迁移数据库更改时 我得到 psycopg2 ProgrammingError permission denied for relation django migrations 其他人已经能够通过