This topic contains a post which is marked as Best Answer. Press here if you would like to see it.
*

siken

  • ****
  • 136 posts
missing many phones to update your themes
« on: September 25, 2019, 12:07:49 AM »
Each theme use own table to store information that cannot be stored in osclass itself.

The idea is to combine the data from the "oc_t_item_veronika" table with the "oc_t_item_alpha" table and with the "oc_t_item_beta table".

I need the consultation, thanks.
« Last Edit: September 25, 2019, 06:31:54 PM by alexandromt »

*

MB Themes

Re: missing many phones to update your themes
« Reply #1 on: September 26, 2019, 02:16:14 PM »
@alexandromt
Try this set of queries

Code: [Select]
REPLACE INTO oc_t_item_beta (fk_i_item_id, s_phone, i_condition, i_transaction)
SELECT fk_i_item_id, s_phone, i_condition, i_transaction FROM oc_t_item_beta where s_phone <> '';

REPLACE INTO oc_t_item_beta (fk_i_item_id, s_phone, i_condition, i_transaction)
SELECT fk_i_item_id, s_phone, i_condition, i_transaction FROM oc_t_item_alpha where s_phone <> '';

REPLACE INTO oc_t_item_beta (fk_i_item_id, s_phone, i_condition, i_transaction)
SELECT fk_i_item_id, s_phone, i_condition, i_transaction FROM oc_t_item_veronika where s_phone <> '';
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

siken

  • ****
  • 136 posts
Re: missing many phones to update your themes
« Reply #2 on: September 26, 2019, 02:37:35 PM »
@alexandromt
Try this set of queries

Code: [Select]
REPLACE INTO oc_t_item_beta (fk_i_item_id, s_phone, i_condition, i_transaction)
SELECT fk_i_item_id, s_phone, i_condition, i_transaction FROM oc_t_item_beta where s_phone <> '';

REPLACE INTO oc_t_item_beta (fk_i_item_id, s_phone, i_condition, i_transaction)
SELECT fk_i_item_id, s_phone, i_condition, i_transaction FROM oc_t_item_alpha where s_phone <> '';

REPLACE INTO oc_t_item_beta (fk_i_item_id, s_phone, i_condition, i_transaction)
SELECT fk_i_item_id, s_phone, i_condition, i_transaction FROM oc_t_item_veronika where s_phone <> '';


The first query and the third one accept it. The second query gives this error:

1452 - cannot add or update a child row: a foreign key constraint fails

Marked as best answer by leales_org on September 26, 2019, 04:48:15 PM
*

siken

  • ****
  • 136 posts
Re: missing many phones to update your themes
« Reply #3 on: September 26, 2019, 04:48:07 PM »
@alexandromt
Try this set of queries

Code: [Select]
REPLACE INTO oc_t_item_beta (fk_i_item_id, s_phone, i_condition, i_transaction)
SELECT fk_i_item_id, s_phone, i_condition, i_transaction FROM oc_t_item_beta where s_phone <> '';

REPLACE INTO oc_t_item_beta (fk_i_item_id, s_phone, i_condition, i_transaction)
SELECT fk_i_item_id, s_phone, i_condition, i_transaction FROM oc_t_item_alpha where s_phone <> '';

REPLACE INTO oc_t_item_beta (fk_i_item_id, s_phone, i_condition, i_transaction)
SELECT fk_i_item_id, s_phone, i_condition, i_transaction FROM oc_t_item_veronika where s_phone <> '';


First I have put the web in maintenance mode.

Then I changed the table name oc_t_item_beta to oc_t_item_beta2

Then I have been adding these sequences in the database:


Code: [Select]
REPLACE INTO oc_t_item_beta_2 (fk_i_item_id, s_phone, i_condition, i_transaction, i_sold)
SELECT fk_i_item_id, s_phone, i_condition, i_transaction, i_sold FROM oc_t_item_beta_leales where s_phone <> '';

REPLACE INTO oc_t_item_beta_2 (fk_i_item_id, s_phone, i_condition, i_transaction, i_sold)
SELECT fk_i_item_id, s_phone, i_condition, i_transaction, i_sold FROM oc_t_item_beta_leales where i_condition <> '';

REPLACE INTO oc_t_item_beta_2 (fk_i_item_id, s_phone, i_condition, i_transaction, i_sold)
SELECT fk_i_item_id, s_phone, i_condition, i_transaction, i_sold FROM oc_t_item_beta_leales where i_transaction <> '';

REPLACE INTO oc_t_item_beta_2 (fk_i_item_id, s_phone, i_condition, i_transaction, i_sold)
SELECT fk_i_item_id, s_phone, i_condition, i_transaction, i_sold FROM oc_t_item_beta_leales where i_sold <> '';

REPLACE INTO oc_t_item_beta_2 (fk_i_item_id, s_phone, i_condition, i_transaction, i_sold)
SELECT fk_i_item_id, s_phone, i_condition, i_transaction, i_sold FROM oc_t_item_veronika where s_phone <> '';

REPLACE INTO oc_t_item_beta_2 (fk_i_item_id, s_phone, i_condition, i_transaction, i_sold)
SELECT fk_i_item_id, s_phone, i_condition, i_transaction, i_sold FROM oc_t_item_veronika where i_condition <> '';

REPLACE INTO oc_t_item_beta_2 (fk_i_item_id, s_phone, i_condition, i_transaction, i_sold)
SELECT fk_i_item_id, s_phone, i_condition, i_transaction, i_sold FROM oc_t_item_veronika where i_transaction <> '';

REPLACE INTO oc_t_item_beta_2 (fk_i_item_id, s_phone, i_condition, i_transaction, i_sold)
SELECT fk_i_item_id, s_phone, i_condition, i_transaction, i_sold FROM oc_t_item_veronika where i_sold <> '';

REPLACE INTO oc_t_item_beta_2 (fk_i_item_id, s_phone, i_condition, i_transaction, i_sold)
SELECT fk_i_item_id, s_phone, i_condition, i_transaction, i_sold FROM oc_t_item_alpha where s_phone <> '';

REPLACE INTO oc_t_item_beta_2 (fk_i_item_id, s_phone, i_condition, i_transaction, i_sold)
SELECT fk_i_item_id, s_phone, i_condition, i_transaction, i_sold FROM oc_t_item_alpha where i_condition <> '';

REPLACE INTO oc_t_item_beta_2 (fk_i_item_id, s_phone, i_condition, i_transaction, i_sold)
SELECT fk_i_item_id, s_phone, i_condition, i_transaction, i_sold FROM oc_t_item_alpha where i_transaction <> '';

REPLACE INTO oc_t_item_beta_2 (fk_i_item_id, s_phone, i_condition, i_transaction, i_sold)
SELECT fk_i_item_id, s_phone, i_condition, i_transaction, i_sold FROM oc_t_item_alpha where i_sold <> '';

I added the i_sold field to the query ...

And finally I renamed the table, from oc_t_item_beta_2 to oc_t_item_beta

And now old ads created with veronika or alpha have their phones with the new beta theme.

When changing the theme, you have to copy the data from the table of the previous theme, so the phones and the states of the ads will be.


Regards