Skip to content
This repository has been archived by the owner on Aug 10, 2021. It is now read-only.

Table 'myproject_development.spree_page_translations' doesn't exist #274

Open
xu4wang opened this issue Apr 13, 2020 · 2 comments
Open

Table 'myproject_development.spree_page_translations' doesn't exist #274

xu4wang opened this issue Apr 13, 2020 · 2 comments

Comments

@xu4wang
Copy link

xu4wang commented Apr 13, 2020

I just installed i18n and globalize gem, please find below the statement in my Gemfile

gem 'spree_static_content', github: 'spree-contrib/spree_static_content'
gem 'spree_i18n', github: 'spree-contrib/spree_i18n'
gem 'spree_globalize', github: 'spree-contrib/spree_globalize'

The spree_static_content was added before and working as expected. However after install i18n and globalize today, the pages can not work. I get error when accessing the pages tab on /admin with below information.

`Showing /Users/wangxu/.gem/ruby/2.7.0/bundler/gems/spree_static_content-a1e066bc612d/app/views/spree/admin/pages/index.html.erb where line #28 raised:

Mysql2::Error: Table 'myproject_development.spree_page_translations' doesn't exist`

@xu4wang
Copy link
Author

xu4wang commented Apr 13, 2020

From the stack trace:

....
activerecord (6.0.2.2) lib/active_record/relation/finder_methods.rb:500:in find_take' activerecord (6.0.2.2) lib/active_record/relation/finder_methods.rb:98:in take'
activerecord (6.0.2.2) lib/active_record/relation/finder_methods.rb:81:in find_by' spree_static_content (a1e066bc612d) lib/spree_static_content.rb:19:in matches?'
actionpack (6.0.2.2) lib/action_dispatch/routing/mapper.rb:40:in block in matches?' actionpack (6.0.2.2) lib/action_dispatch/routing/mapper.rb:39:in all?'
actionpack (6.0.2.2) lib/action_dispatch/routing/mapper.rb:39:in `matches?'
....

Checked the source of lib/spree_static_content.rb,

694bce5#diff-5627e6f87e4b5791c859c7a51762eef9

It looks like the issue was introduced by commit 694bce5, "Make SpreeGlobalize optional" . The SpreeGlobalize didn't create spree_page_translations.

@damianlegawiec

@xu4wang
Copy link
Author

xu4wang commented Apr 13, 2020

checked the migration file of static_content gem, it did try to create the translation table.

This migration comes from spree_static_content (originally 20170827000001)

class AddTranslationToSpreePages < SpreeExtension::Migration[4.2]
def up
params = { title: :string, body: :text, slug: :string, foreign_link: :string, meta_keywords: :string, meta_title: :string, meta_description: :string }
if defined?(SpreeGlobalize)
Spree::Page.create_translation_table!(params, { migrate_data: true })
end
end

def down
if defined?(SpreeGlobalize)
Spree::Page.drop_translation_table! migrate_data: true
end
end
end

I understand the issue I'm facing is I install static_content gem first, and spree globalize gem later. Which makes the translation table not generated.

How shall I do? Is there a way to re-run the migration files and regenerate the translation table?

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

No branches or pull requests

1 participant