I've ran into a problem in which I'm not sure how to get out of this. Working on creating a rails view, and after populating my view and editing my controller, i've ran into an error that states PG::UndefinedTable: ERROR: relation 'caves' does not exist
Looking into what I did, I realized that I created my model as cafe but when I populated my schema tables, I accidentally created a table called caves instead of cafes.
Here's what I did to try to resolve this.
I first tried creating a migration to just rename the table from caves to cafes -- still ran into the same error
I then tried deleting the schema table all together and creating a new one all together called cafe - still ran into the same error
I then tried dropping my database all together, thinking if I just wiped the whole thing and started over (i just started on this rails project). I ran rake db:reset only to come into a new error telling me ActiveRecord::StatementInvalid: PG::ObjectInUse: ERROR: database "cafe_database" is being accessed by other users
By this point, I tried restarted my postgress and ran sudo service postgresql restart....but my machine doesn't recognize service
Does anybody have an idea what I can do to figure this problem out? I'm running out of ideas.
try below steps:
1. rake db:drop
2. rake db:create
3. rake db:migrate
Related
On my local system, I am facing an error of Statement Invalid. Previously, I was not getting this, but I think when I reindexed my elastic search after adding the taxon_ids index, this error started to come. Please check the attached screenshot.
And version details are -
Mysql - 5.7.34-0ubuntu0.18.04.1
Rails - 4.2.7.1
Ruby - 2.3.1
Please advise on how it can be resolved.
The Error says that your Database is missing some columns. Can you run
rake db:migrate
i've finished developing a django project and wanted to change sqlite3 to MySql for a better database option. I tried in an empty project to change database, it worked like a charm. But now i changed db of my project and when i try to do python manage.py makemigrations it returns;
django.db.utils.ProgrammingError: (1146, "Table 'tvekstra-django-tracker.tvchannels_channels' doesn't exist")
Any help is appreciated, thanks.
I guess you have code that is trying to query the database before makemigrations runs. Here is a similar question. To help with your specific problem, you need to show the full traceback which will show where the query is occuring, and your views.py.
I am building an app with Ruby/Rails and using a MySQL database.
Recently, I started having the following issue: sometimes, when doing a Rails migration, Rails drops my DB table!
When it drops the table it gives the following error:
"MySQL2:error: Lost connection to MySQL server during query: ALTER TABLE . . ."
My internet connection is good. It has happened twice so far. The first time the migration involved the following methods: remove_column, add_column, add_foreign_key. The second time it contained only remove_column and add_column.
The migrations are not huge files with a maximum of 10 lines.
Why is it doing this? What can I do to fix it?
Lately I am working on my beautiful tests, but suddenly, after a 2 days rest, I ran again my integration tests (rake test:integration) and they don't work anymore. I really didn't do anything.
What comes is the following error:
Mysql2::Error: Can't connect to MySQL server on '192.168.0.2'
The nice thing is that the server runs fine. It is just the integration test that is broken. And they use the same mysql database.
Any idea on how to solve the problem?
Luca
check your database.yml settings about test environment and then make in terminal
rake db:test:load
Check the DB using mysql workbench if you not find errors as user permissions... delete and create again DB for app. rake db:drop && rake db:setup
I taking over an existing rails project. I currently trying to get the db setup. I have run rake db:create and the DB was created. I need to get the tables created. I have tried db:scheme:load, db:setup and db:migrate. All give me this error:
Mysql2::Error: Table 'blah' doesn't exist: SHOW FULL FIELDS FROM blahs
Then a long stack trace with nothing very helpful.
Thanks for any help!
Check the migrations, there would be something like 'blah' (left by developer)