- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
对于初学者,我使用两个不同的数据库,开发中的 sqlite 和生产中的 postgresql。
我认为这个问题与我的数据库更改后忘记不断迁移到 heroku 有关。在迁移到 heroku 之前,我可能在本地进行了四到五次迁移。所以无论如何,问题是当我 tun heroku run rails db:migrate
我收到一条错误消息说 PG::UndefinedTable: ERROR: relation "users"does not exist
虽然在开发中它确实如此。我会尝试在下面附上所有必要的信息。如果有任何遗漏,请告诉我。
架构.rb
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20161011053831) do
create_table "comments", force: :cascade do |t|
t.integer "user_id"
t.text "body"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "post_id"
t.index ["post_id"], name: "index_comments_on_post_id"
t.index ["user_id"], name: "index_comments_on_user_id"
end
create_table "posts", force: :cascade do |t|
t.string "title"
t.text "body"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "users", force: :cascade do |t|
t.string "first_name"
t.string "last_name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end
end
终端输出
Running rails db:migrate on ⬢ [retracted]... up, run.1231 (Free)
D, [2016-10-11T06:15:07.562673 #3] DEBUG -- : (0.8ms) SELECT pg_try_advisory_lock(6976026441189414000);
D, [2016-10-11T06:15:07.572811 #3] DEBUG -- : ActiveRecord::SchemaMigration Load (1.0ms) SELECT "schema_migrations".* FROM "schema_migrations"
I, [2016-10-11T06:15:07.577534 #3] INFO -- : Migrating to CreateComments (20160928024026)
D, [2016-10-11T06:15:07.579481 #3] DEBUG -- : (0.7ms) BEGIN
== 20160928024026 CreateComments: migrating ===================================
-- create_table(:comments)
D, [2016-10-11T06:15:07.594892 #3] DEBUG -- : (13.9ms) CREATE TABLE "comments" ("id" serial primary key, "user_id" integer, "body" text, "blog_post_id" integer, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL, CONSTRAINT "fk_rails_03de2dc08c"
FOREIGN KEY ("user_id")
REFERENCES "users" ("id")
, CONSTRAINT "fk_rails_29c545254e"
FOREIGN KEY ("blog_post_id")
REFERENCES "blog_posts" ("id")
)
D, [2016-10-11T06:15:07.595917 #3] DEBUG -- : (0.7ms) ROLLBACK
D, [2016-10-11T06:15:07.597131 #3] DEBUG -- : (0.9ms) SELECT pg_advisory_unlock(6976026441189414000)
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::UndefinedTable: ERROR: relation "users" does not exist
: CREATE TABLE "comments" ("id" serial primary key, "user_id" integer, "body" text, "blog_post_id" integer, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL, CONSTRAINT "fk_rails_03de2dc08c"
FOREIGN KEY ("user_id")
REFERENCES "users" ("id")
, CONSTRAINT "fk_rails_29c545254e"
FOREIGN KEY ("blog_post_id")
REFERENCES "blog_posts" ("id")
)
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `async_exec'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `block in execute'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:566:in `block in log'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:560:in `log'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:97:in `execute'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:283:in `create_table'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:845:in `block in method_missing'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:814:in `block in say_with_time'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:814:in `say_with_time'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:834:in `method_missing'
/app/db/migrate/20160928024026_create_comments.rb:3:in `change'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:788:in `exec_migration'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:772:in `block (2 levels) in migrate'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:771:in `block in migrate'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:398:in `with_connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:770:in `migrate'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:950:in `migrate'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1211:in `block in execute_migration_in_transaction'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1279:in `block in ddl_transaction'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `block in transaction'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/transaction.rb:189:in `within_new_transaction'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `transaction'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:211:in `transaction'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1279:in `ddl_transaction'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1210:in `execute_migration_in_transaction'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1183:in `block in migrate_without_lock'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1182:in `each'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1182:in `migrate_without_lock'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1131:in `block in migrate'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1298:in `with_advisory_lock'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1131:in `migrate'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1005:in `up'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:983:in `migrate'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/tasks/database_tasks.rb:161:in `migrate'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/rake_proxy.rb:13:in `block in run_rake_task'
/app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/rake_proxy.rb:10:in `run_rake_task'
/app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:51:in `run_command!'
/app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
/app/bin/rails:9:in `require'
/app/bin/rails:9:in `<main>'
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "users" does not exist
: CREATE TABLE "comments" ("id" serial primary key, "user_id" integer, "body" text, "blog_post_id" integer, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL, CONSTRAINT "fk_rails_03de2dc08c"
FOREIGN KEY ("user_id")
REFERENCES "users" ("id")
, CONSTRAINT "fk_rails_29c545254e"
FOREIGN KEY ("blog_post_id")
REFERENCES "blog_posts" ("id")
)
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `async_exec'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `block in execute'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:566:in `block in log'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:560:in `log'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:97:in `execute'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:283:in `create_table'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:845:in `block in method_missing'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:814:in `block in say_with_time'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:814:in `say_with_time'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:834:in `method_missing'
/app/db/migrate/20160928024026_create_comments.rb:3:in `change'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:788:in `exec_migration'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:772:in `block (2 levels) in migrate'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:771:in `block in migrate'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:398:in `with_connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:770:in `migrate'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:950:in `migrate'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1211:in `block in execute_migration_in_transaction'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1279:in `block in ddl_transaction'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `block in transaction'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/transaction.rb:189:in `within_new_transaction'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `transaction'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:211:in `transaction'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1279:in `ddl_transaction'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1210:in `execute_migration_in_transaction'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1183:in `block in migrate_without_lock'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1182:in `each'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1182:in `migrate_without_lock'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1131:in `block in migrate'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1298:in `with_advisory_lock'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1131:in `migrate'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1005:in `up'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:983:in `migrate'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/tasks/database_tasks.rb:161:in `migrate'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/rake_proxy.rb:13:in `block in run_rake_task'
/app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/rake_proxy.rb:10:in `run_rake_task'
/app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:51:in `run_command!'
/app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
/app/bin/rails:9:in `require'
/app/bin/rails:9:in `<main>'
PG::UndefinedTable: ERROR: relation "users" does not exist
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `async_exec'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `block in execute'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:566:in `block in log'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:560:in `log'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:97:in `execute'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:283:in `create_table'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:845:in `block in method_missing'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:814:in `block in say_with_time'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:814:in `say_with_time'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:834:in `method_missing'
/app/db/migrate/20160928024026_create_comments.rb:3:in `change'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:788:in `exec_migration'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:772:in `block (2 levels) in migrate'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:771:in `block in migrate'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:398:in `with_connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:770:in `migrate'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:950:in `migrate'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1211:in `block in execute_migration_in_transaction'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1279:in `block in ddl_transaction'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `block in transaction'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/transaction.rb:189:in `within_new_transaction'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `transaction'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/transactions.rb:211:in `transaction'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1279:in `ddl_transaction'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1210:in `execute_migration_in_transaction'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1183:in `block in migrate_without_lock'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1182:in `each'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1182:in `migrate_without_lock'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1131:in `block in migrate'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1298:in `with_advisory_lock'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1131:in `migrate'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:1005:in `up'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/migration.rb:983:in `migrate'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/tasks/database_tasks.rb:161:in `migrate'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-5.0.0.1/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/rake_proxy.rb:13:in `block in run_rake_task'
/app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/rake_proxy.rb:10:in `run_rake_task'
/app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:51:in `run_command!'
/app/vendor/bundle/ruby/2.2.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
/app/bin/rails:9:in `require'
/app/bin/rails:9:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
我已经尝试了一些其他的解决方案,但到目前为止都没有奏效。谢谢!
最佳答案
看起来你在 users
之前创建了 comments
表,同时在 comments
中使用了 user_id
外键table 它失败了,因为还没有这样的表。
确保您的迁移顺序正确(用户,然后是评论)。
通常,您应该始终首先创建表/列,只有在创建和迁移它们之后,才引用它们。
关于ruby-on-rails - 问题将数据库迁移到 Heroku - PG::UndefinedTable: ERROR: relation "users"does not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39971733/
运行马里奥游戏时此文件出现错误当我尝试运行文件 super_mario.py 时,我从以下链接( https://github.com/Ja1r0/DQN-play-SuperMario )下载了代码
来自pg module doc ,似乎连接到 PG 数据库的正确方法是使用: conn = PG::Connection.open(dbname: 'test') 但是,我发现 other examp
嘿,所以我试图让 Nodejs Koa 使用 Koa-pg 模块与 postgres 对话,但我一直收到“找不到模块 pg”错误。我已尝试遵循 koa-pg 示例,但效果不佳……因此,我们将不胜感激任
我需要一些关于 pg npm 的帮助。 我已经阅读了许多文章和示例,并且对以正确的方式使用 pg 池感到非常困惑。许多文章都是我读过的旧文章。 我想向您展示我的一些代码以及我是如何围绕 db 构建所有
我有一个 postgresql 表,每天都有数千条时间序列数据。我有一个应用程序允许用户检索这些数据。查询可能需要 200 毫秒到 30 秒,具体取决于时间范围,因此这些查询必须是可取消的,以避免对生
我不确定我的 heroku postgres 发生了什么,但是当我尝试使用命令行访问它时 pg:info和 pg:psql ,我得到“未找到”。 我什至单击 heroku 上的按钮也为我的应用程序创建
给定一个包含 jsonb[] 类型列的表,如何将 json 数组插入到该列中? 使用提供的格式化程序 :array、:json 在这种情况下将不起作用 - 除非我缺少正确的组合或其他内容。 const
我是 node 和 pg-promise 的新手,一直无法弄清楚如何将三个相关查询的结果合并到一个 json 结果中。 给定三个相关表: 父实体 create table parent ( id bi
在开发时,我需要拉取最新的数据库,以便我知道我正在使用最新的数据。但是,我们保留了一张表,里面装满了我不需要费心下载的文件,因为它是一个非常大的表。 我知道 pg_dump 允许自定义参数,这些参数可
当我运行时(作为 root) gem install pg -v '0.12.0' -- --with-pg-config=/usr/pgsql-9.1/bin/pg_config 我得到以下输出:
我在尝试使用annotation@type(type=“pg uuid”)时遇到了一些问题。它抛出此异常: Caused by: java.lang.ClassNotFoundException: C
我按照这个线程 (Cannot install pg gem in Mavericks with Postgres.app) 获得了 'pg' gem 成功地与 Mavericks 上的 Postgr
正在获取 pg:找不到模型 id="," 的 dst 值 我定义了以下模型 // omitting fields which don't seem relevant to the issue // c
如何在Ruby pg gem 中使用PG::Connection 类的公共(public)实例方法send_query? 它可以帮助加快这样的程序的执行时间吗? a = [1,2,3,4,5,6,..
大家好,我一直在尝试使用 capistrano 部署我的应用程序。但是,我始终收到以下错误,并且不知道如何解决它。 * executing "cd /var/www/html/mysite.com/r
在我的 TestLogger 类中,require 'pg'(版本 0.16.0)返回 true,但 PGconn 未注册。 到目前为止,只有服务器有这个问题,而且只在TestLogger。其他确实需
使用 VSCode。为 Windows 安装了最新的 Node.js(首次用户)以及所需的模块,其中一个是“pg”(npm install pg) 在我的脚本顶部有这样的内容:const pg = r
我写了一个简单的脚本:。This.db对应于一个Pool对象。所以我在数据库中选择了一个特定的对象,在它的旁边我试图取回相同的对象,但这次使用了creation_date字段。。我尝试了许多结果变量更
我做了一个简单的脚本:。This.db对应于Pool对象。因此,我使用他的ID在我的数据库中选择了一个特定的对象。在它旁边,我试图取回相同的对象,但这次使用的是Creation_Date字段。。我尝试
我希望执行以下操作。 使用 group by 查询查询大型表以执行值汇总。 通过例程运行这些记录以添加一些附加数据 将它们高效地插入数据库。 我尝试使用 pg-query-stream 将数据作为流读
我是一名优秀的程序员,十分优秀!