Skip to content

Instantly share code, notes, and snippets.

@djgraham
Last active January 29, 2016 10:39
Show Gist options
  • Save djgraham/f0a44f4eb714e6f9aad1 to your computer and use it in GitHub Desktop.
Save djgraham/f0a44f4eb714e6f9aad1 to your computer and use it in GitHub Desktop.
Postgres queries top copy translation table data into their main parent model fields in Spree (When you want to remove the spree_i18n gem)
update spree_option_types set name = t1.name, presentation = t1.presentation from spree_option_type_translations as t1 where spree_option_types.id = t1.spree_option_type_id AND t1.locale = 'en';
update spree_option_values set name = t1.name, presentation = t1.presentation from spree_option_value_translations as t1 where spree_option_values.id = t1.spree_option_value_id AND t1.locale = 'en';
update spree_products set name = t1.name, description = t1.description, meta_description = t1.meta_description, meta_keywords = t1.meta_keywords, slug = t1.slug from spree_product_translations as t1 where spree_products.id = t1.spree_product_id and t1.locale = 'en';
update spree_promotions set name = t1.name, description = t1.description from spree_promotion_translations as t1 where spree_promotions.id = t1.spree_promotion_id AND t1.locale = 'en';
update spree_properties set name = t1.name, presentation = t1.presentation from spree_property_translations as t1 where spree_properties.id = t1.spree_property_id AND t1.locale = 'en';
update spree_taxonomies set name = t1.name from spree_taxonomy_translations as t1 where spree_taxonomies.id = t1.spree_taxonomy_id AND t1.locale = 'en';
update spree_taxons set name = t1.name, permalink = t1.permalink from spree_taxon_translations as t1 where spree_taxons.id = t1.spree_taxon_id AND t1.locale = 'en';
update spree_product_properties set value = trim(regexp_replace(trim(regexp_replace(t1.value, E'[\\n\\r-]+', '', 'g' )),'\.\.\.','')) from spree_product_property_translations as t1 where spree_product_properties.id = t1.spree_product_property_id AND t1.locale = 'en';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment