Heroku 只初始化我的一些模型
所以我跑了
heroku db:push
,它返回了
Sending schema
Schema: 100% |==========================================| Time: 00:00:08
Sending indexes
schema_migrat: 100% |==========================================| Time: 00:00:00
projects: 100% |==========================================| Time: 00:00:00
tasks: 100% |==========================================| Time: 00:00:00
users: 100% |==========================================| Time: 00:00:00
Sending data
8 tables, 70,551 records
groups: 100% |==========================================| Time: 00:00:00
schema_migrat: 100% |==========================================| Time: 00:00:00
projects: 100% |==========================================| Time: 00:00:00
tasks: 100% |==========================================| Time: 00:00:02
authenticatio: 100% |==========================================| Time: 00:00:00
articles: 100% |==========================================| Time: 00:08:27
users: 100% |==========================================| Time: 00:00:00
topics: 100% |==========================================| Time: 00:01:22
Resetting sequences
,当我去
heroku console
这工作了,
>> Task
=> Task(id: integer, topic: string, content: string,
这工作了,
>> User
=> User(id: integer, name: string, email: string,
但其余的只返回了类似
>> Project
NameError: uninitialized constant Project
/home/heroku_rack/lib/console.rb:150
/home/heroku_rack/lib/console.rb:150:in `call'
/home/heroku_rack/lib/console.rb:28:in `call'
>> Authentication
NameError: uninitialized constant Authentication
/home/heroku_rack/lib/console.rb:150
/home/heroku_rack/lib/console.rb:150:in `call'
更新1:
的东西,当我输入
>> ActiveRecord::Base.connection.tables
它
=> ["projects", "groups", "tasks", "topics", "articles", "schema_migrations", "authentications", "users"]
使用heroku的SQL控制台插件
时,我得到了
SQL> show tables
+-------------------+
| table_name |
+-------------------+
| authentications |
| topics |
| groups |
| projects |
| schema_migrations |
| tasks |
| articles |
| users |
+-------------------+
,所以我认为它们是已经存在于heroku的数据库中。
rack db:migrate 可能有问题
更新 2:
我在生产和开发模式下都在本地运行了rack db:migrate,没有发生任何错误。
但是当我在heroku上运行它时 它只返回:
$ heroku rake db:migrate
(in /disk1/home/slugs/389817_1c16250_4bf2-f9c9517b-bdbd-49d9-8e5a-a87111d3558e/mnt)
$
另外,我正在使用 sqlite3
update 3:
所以我打开了 heroku 控制台并输入以下命令令人
class Authentication < ActiveRecord::Base;end
惊讶的是我能够调用 Authentication 类,但是一旦退出,什么都没有改变。
So I ran
heroku db:push
And it returned
Sending schema
Schema: 100% |==========================================| Time: 00:00:08
Sending indexes
schema_migrat: 100% |==========================================| Time: 00:00:00
projects: 100% |==========================================| Time: 00:00:00
tasks: 100% |==========================================| Time: 00:00:00
users: 100% |==========================================| Time: 00:00:00
Sending data
8 tables, 70,551 records
groups: 100% |==========================================| Time: 00:00:00
schema_migrat: 100% |==========================================| Time: 00:00:00
projects: 100% |==========================================| Time: 00:00:00
tasks: 100% |==========================================| Time: 00:00:02
authenticatio: 100% |==========================================| Time: 00:00:00
articles: 100% |==========================================| Time: 00:08:27
users: 100% |==========================================| Time: 00:00:00
topics: 100% |==========================================| Time: 00:01:22
Resetting sequences
And when I went to
heroku console
This worked
>> Task
=> Task(id: integer, topic: string, content: string,
This worked
>> User
=> User(id: integer, name: string, email: string,
But the rest only returned something like
>> Project
NameError: uninitialized constant Project
/home/heroku_rack/lib/console.rb:150
/home/heroku_rack/lib/console.rb:150:in `call'
/home/heroku_rack/lib/console.rb:28:in `call'
>> Authentication
NameError: uninitialized constant Authentication
/home/heroku_rack/lib/console.rb:150
/home/heroku_rack/lib/console.rb:150:in `call'
update 1:
And when I typed
>> ActiveRecord::Base.connection.tables
it returned
=> ["projects", "groups", "tasks", "topics", "articles", "schema_migrations", "authentications", "users"]
Using heroku's SQL console plugin
I got
SQL> show tables
+-------------------+
| table_name |
+-------------------+
| authentications |
| topics |
| groups |
| projects |
| schema_migrations |
| tasks |
| articles |
| users |
+-------------------+
So I think they are existing in heroku's database already.
There is probably something wrong with rack db:migrate
update 2:
I ran rack db:migrate locally in both production and development modes and nothing wrong happened.
But when I ran it on heroku
it only returned:
$ heroku rake db:migrate
(in /disk1/home/slugs/389817_1c16250_4bf2-f9c9517b-bdbd-49d9-8e5a-a87111d3558e/mnt)
$
Also, I am using sqlite3
update 3:
so I opened up heroku console and typed in the following command
class Authentication < ActiveRecord::Base;end
Amazingly I was able to call Authentication class, but once I exited, nothing was changed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
此错误:
表示项目模型丢失,这不属于数据库。
尝试:
This error:
means that Project model is missing, this is not belongs to the database.
try:
你称它为
pojects
,它出现并且authenticato
另外,你已经heroku重新启动了应用程序,对吧?
哦,你已经在 git 中提交了文件,并且我希望也做了正常的 git push heroku master 吗?
你只是一直在谈论heroku db:push,我在日常提交中几乎从不使用该命令。
you called it
pojects
it appears andauthenticato
Also, you've heroku restarted the app right?
Oh, and you have commited the files in git and did a normal
git push heroku master
i hope as well?you just keep talking about heroku db:push which i hardly ever use that command in day to day commits.
如果您实际上缺少 SQLite 中的表,您会看到类似
Project(Table does not exit)
的错误If you were actually missing the Tables in SQLite you would see an error like
Project(Table doesn't exist)