Migrating db of existing project - mysql

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)

Related

ActiveRecord::StatementInvalid in Rails 4.2.7.1

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

Getting error after changed sqlite to mysql, table doesn't exist?

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.

PG::UndefinedTable: ERROR: relation 'caves' does not exist

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

Rails integration test: Mysql2::Error: Can't connect to MySQL server

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

Connection problems with Rails and MySQL

So I was making some tests here on Rails and for first time I decide to use MySQL, I've setting up the gem mysql2 and the mysql server.
When I try to access the database I receive this:
ActiveRecord::ConnectionNotEstablished
The strange thing is I'm able to run the rake db:create and the migrations without any problems.
thanks in advance,
Renan
ActiveRecord::ConnectionNotEstablished
Raised when connection to the database could not been established (for example when connection= is given a nil object).
Try checking your db configurations in the config/database.yml file if everything is correct or not!!