Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table 'db.versions' doesn't exist: SHOW FULL FIELDS FROM versions #401

Closed
stan opened this issue Jul 24, 2014 · 15 comments
Closed

Table 'db.versions' doesn't exist: SHOW FULL FIELDS FROM versions #401

stan opened this issue Jul 24, 2014 · 15 comments
Milestone

Comments

@stan
Copy link

stan commented Jul 24, 2014

Papertrail 3.0.3 and Rails 4.1.4

Using only custom version classes, getting ActiveRecord::StatementInvalid (Mysql2::Error: Table 'db.versions' doesn't exist: SHOW FULL FIELDS FROM versions) error every time a change is made to a model in development (need to restart dev env to fix), despite using the recommended initializer:

# config/initializers/paper_trail.rb

# the following line is required for PaperTrail >= 3.0.3 with Rails
PaperTrail::Rails::Engine.eager_load!

PaperTrail::Version.module_eval do
  self.abstract_class = true
end

I do not want to create a dummy versions table. Works fine in 3.0.2

@batter
Copy link
Collaborator

batter commented Jul 25, 2014

What happens if you remove the line to eager load the rails engine? Does
that fix it?

Sent from my iPhone

On Jul 24, 2014, at 12:25 PM, stan Mazurek [email protected] wrote:

Papertrail 3.0.3 and Rails 4.1.4

Using only custom version classes, getting ActiveRecord::StatementInvalid
(Mysql2::Error: Table 'db.versions' doesn't exist: SHOW FULL FIELDS FROM
versions) error every time a change is made to a model in development (need
to restart dev env to fix), despite using the recommended initializer:

config/initializers/paper_trail.rb

the following line is required for PaperTrail >= 3.0.3 with Rails

PaperTrail::Rails::Engine.eager_load!

PaperTrail::Version.module_eval do
self.abstract_class = true
end

I do not want to create a dummy versions table. Works fine in 3.0.2


Reply to this email directly or view it on GitHub
#401.

@stan
Copy link
Author

stan commented Jul 25, 2014

Same issue without the eager load line (just added it after I saw b9b0d17 but didn't help)

@batter
Copy link
Collaborator

batter commented Jul 25, 2014

Can you actually try putting the eager load line AFTER the module_eval block and see if that helps? Sorry for the confusion. If that doesn't work I might need some more info on how to reproduce this to get to the bottom of it.

Also can you go into detail a bit more about how to reproduce? This happens when you are running the rails server and you modify a model and save it? Which models are you modifying and how? I just ran a local app and wasn't able to reproduce..

@stan
Copy link
Author

stan commented Jul 29, 2014

Same thing when putting the eager load line after the module_eval block.

I have a Team model (among others) using PaperTrail

class Team < ActiveRecord::Base
  has_paper_trail class_name: 'TeamVersion', ignore: %i(updated_by_id)
end

Starting rails server with bin/rails s -e development everything works fine, I can update teams, etc..
Then doing any change to the app/models/team.rb file (i.e. adding a blank line) will trigger the error next time I update a team object.

Hope this helps.

@bvogel
Copy link

bvogel commented Aug 6, 2014

I can confirm this issue (with rails 4.1.4 and ruby 2.1.2). I can also reproduce it by changing a locale yml (config/locales/en.yml). And I get the error if I change ANY model, not only one that uses paper_trail.

@batter
Copy link
Collaborator

batter commented Aug 6, 2014

Can you guys reproduce this with PaperTrail version 3.0.2? or are you only seeing this with version 3.0.3?

I'm considering yanking PaperTrail 3.0.3, and releasing a 3.0.4 with the Rails::Engine model loading feature backed out (and then re-inserting it for 3.1.0).

@stan
Copy link
Author

stan commented Aug 6, 2014

Only happens with 3.0.3

Would make sense considering it's a patch release.

@hajpoj
Copy link

hajpoj commented Aug 7, 2014

I can also reproduce it on 3.0.3 (rails 4.1.4, ruby 2.1.2) with inconsistent results. It appears that restarting the server after setting self.table_name fixes the problem.

Repo steps on 3.0.3 for a UpdateVersion class and Table:

  1. self.table_name = :update_versions
  2. try to make an update (works fine)
  3. change table_name = :versions
  4. try to make an update (error!)
  5. change table_name back to = :update_versions
  6. try to make an update (error!)
  7. restart server
  8. try to make an update (works fine)

Repo steps on 3.0.2 for a UpdateVersion class and Table
with # PaperTrail::Rails::Engine.eager_load! removed:

  1. self.table_name = :update_versions
  2. try to make an update (works fine)
  3. change table_name = :versions
  4. try to make an update (error!)
  5. change table_name back to = :update_versions
  6. try to make an update (works fine!)

So with 3.0.3 it appears to work once you restart, while with 3.0.2 works by just changing the table_name variable to the correct value.

Hope that helps.

@batter
Copy link
Collaborator

batter commented Aug 7, 2014

Yea I'm not sure if you can change the table_name directive for a model without restarting the server, even when PaperTrail is not in usage. I think because ActiveRecord maps out it's tables prior to the server starting up. Am I mistaken about that?

@hajpoj
Copy link

hajpoj commented Aug 7, 2014

At least in development, you can set and change self.table_value and have it take effect without restarting the server.

@mockdeep
Copy link
Contributor

Running into the same problem here on rails 3.2.19. Restarting the server didn't help for us. Downgrading to 3.0.2 got us the error uninitialized constant PaperTrail::Rails::Engine.

@NullVoxPopuli
Copy link
Contributor

I also have the same problem.

ActiveRecord::StatementInvalid - Mysql2::Error: Table 'app.versions' doesn't exist: SHOW FULL FIELDS FROM versions:

rails 3.2.18

@batter batter closed this as completed in 58b0bad Aug 29, 2014
@batter
Copy link
Collaborator

batter commented Aug 29, 2014

Please try version 3.0.5, which was just released and should alleviate your issues.

@batter batter added this to the 3.0.5 milestone Sep 2, 2014
@ngelx
Copy link

ngelx commented Jun 13, 2015

Hi, i'm having exactly the same issue with version 4.0.0.rc1 Rails 4.2 and ruby 2.1.2. I've set up paper_trail.rb initialiser as described on the doc, and got some custom version tables.

Edited: I've found this that seems to be pretty the same #488 #526 and solution seems to be in #492 but not sure

@stan
Copy link
Author

stan commented Jun 21, 2015

Issue is back (4.0.0.rc1 / ruby 2.1.5 / Rails 4.2.2) - fixed for me by #492

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants