Advertisement
padznich

Untitled

Apr 8th, 2018
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 12.52 KB | None | 0 0
  1. --
  2. -- yield_calendar_omission
  3. --
  4. DELETE FROM
  5.   e_restaurant.yield_calendar_omission
  6. WHERE
  7.   restaurant_id < 5000000;
  8. REPLACE INTO e_restaurant.yield_calendar_omission (id, restaurant_id, version, data, created_at, updated_at)
  9.   SELECT
  10.     r.pkrestaurantid                                                          AS id,
  11.     r.pkrestaurantid                                                          AS resturant_id,
  12.     1                                                                         AS version,
  13.     (SELECT CONCAT('[', GROUP_CONCAT(JSON_OBJECT(
  14.                                        'StartDate', DATE_FORMAT(convert_tz(re.exceptionfromdate,
  15.                                                                            IF(r.fkcountryid = 185, 'Asia/Singapore',
  16.                                                                               'Asia/Bangkok'), 'GMT'),
  17.                                                                 IF(r.fkcountryid = 185, '%Y-%m-%dT%H:%i:%S+08:00',
  18.                                                                    '%Y-%m-%dT%H:%i:%S+07:00')),
  19.                                        'StartTime', IF(re.exceptionfullday = 'Yes',
  20.                                                        0,
  21.                                                        convert(re.exceptionfromtime * 100, SIGNED)),
  22.                                        'EndDate', DATE_FORMAT(convert_tz(re.exceptiontodate,
  23.                                                                          IF(r.fkcountryid = 185, 'Asia/Singapore',
  24.                                                                             'Asia/Bangkok'),
  25.                                                                          'GMT'),
  26.                                                               IF(r.fkcountryid = 185, '%Y-%m-%dT%H:%i:%S+08:00',
  27.                                                                  '%Y-%m-%dT%H:%i:%S+07:00')),
  28.                                        'EndTime', IF(re.exceptionfullday = 'Yes',
  29.                                                      2330,
  30.                                                      convert(re.exceptiontotime * 100, SIGNED))
  31.                                    )),
  32.                  ']')
  33.     FROM
  34.       ebdb.restaurant_exceptions re
  35.     WHERE r.pkrestaurantid = re.fkrestaurantid AND re.exceptiondatetype = 1) AS data,
  36.     convert_tz((SELECT min(exceptiondateadded)
  37.               FROM ebdb.restaurant_exceptions
  38.               WHERE r.pkrestaurantid = fkrestaurantid AND exceptiondatetype = 1
  39.               LIMIT 1), IF(r.fkcountryid = 185, 'Asia/Singapore', 'Asia/Bangkok'),
  40.              'GMT')                                                         AS created_at,
  41.     convert_tz((SELECT max(exceptiondateadded)
  42.               FROM ebdb.restaurant_exceptions
  43.               WHERE r.pkrestaurantid = fkrestaurantid AND exceptiondatetype = 1
  44.               LIMIT 1), IF(r.fkcountryid = 185, 'Asia/Singapore', 'Asia/Bangkok'),
  45.              'GMT')                                                         AS updated_at
  46.   FROM ebdb.restaurant r
  47.   WHERE (SELECT count(1)
  48.          FROM ebdb.restaurant_exceptions re0
  49.          WHERE re0.fkrestaurantid = r.pkrestaurantid AND re0.exceptiondatetype = 1) > 0;
  50. REPLACE INTO e_restaurant.yield_calendar_omission (id, restaurant_id, version, data, created_at, updated_at)
  51.   SELECT
  52.     r.pkrestaurantid                                                          AS id,
  53.     r.pkrestaurantid                                                          AS resturant_id,
  54.     1                                                                         AS version,
  55.     (SELECT CONCAT('[', GROUP_CONCAT(JSON_OBJECT(
  56.                                        'StartDate', DATE_FORMAT(convert_tz(re.exceptionfromdate, 'Asia/Kuala_Lumpur', 'GMT'),
  57.                                                                 '%Y-%m-%dT%H:%i:%S+08:00'),
  58.                                        'StartTime', IF(re.exceptionfullday = 'Yes',
  59.                                                        0,
  60.                                                        convert(re.exceptionfromtime * 100, SIGNED)),
  61.                                        'EndDate', DATE_FORMAT(convert_tz(re.exceptiontodate, 'Asia/Kuala_Lumpur', 'GMT'),
  62.                                                               '%Y-%m-%dT%H:%i:%S+08:00'),
  63.                                        'EndTime', IF(re.exceptionfullday = 'Yes',
  64.                                                      2330,
  65.                                                      convert(re.exceptiontotime * 100, SIGNED))
  66.                                    )),
  67.                  ']')
  68.     FROM
  69.       my_eatigo.restaurant_exceptions re
  70.     WHERE r.pkrestaurantid = re.fkrestaurantid AND re.exceptiondatetype = 1) AS data,
  71.     convert_tz((SELECT min(exceptiondateadded)
  72.               FROM my_eatigo.restaurant_exceptions
  73.               WHERE r.pkrestaurantid = fkrestaurantid AND exceptiondatetype = 1
  74.               LIMIT 1), 'Asia/Kuala_Lumpur',
  75.              'GMT')                                                         AS created_at,
  76.     convert_tz((SELECT max(exceptiondateadded)
  77.               FROM my_eatigo.restaurant_exceptions
  78.               WHERE r.pkrestaurantid = fkrestaurantid AND exceptiondatetype = 1
  79.               LIMIT 1), 'Asia/Kuala_Lumpur',
  80.              'GMT')                                                         AS updated_at
  81.   FROM my_eatigo.restaurant r
  82.   WHERE (SELECT count(1)
  83.          FROM my_eatigo.restaurant_exceptions re0
  84.          WHERE re0.fkrestaurantid = r.pkrestaurantid AND re0.exceptiondatetype = 1) > 0;
  85. REPLACE INTO e_restaurant.yield_calendar_omission (id, restaurant_id, version, data, created_at, updated_at)
  86.   SELECT
  87.     r.pkrestaurantid                                                          AS id,
  88.     r.pkrestaurantid                                                          AS resturant_id,
  89.     1                                                                         AS version,
  90.     (SELECT CONCAT('[', GROUP_CONCAT(JSON_OBJECT(
  91.                                        'StartDate', DATE_FORMAT(convert_tz(re.exceptionfromdate, 'Asia/Hong_Kong', 'GMT'),
  92.                                                                 '%Y-%m-%dT%H:%i:%S+08:00'),
  93.                                        'StartTime', IF(re.exceptionfullday = 'Yes',
  94.                                                        0,
  95.                                                        convert(re.exceptionfromtime * 100, SIGNED)),
  96.                                        'EndDate', DATE_FORMAT(convert_tz(re.exceptiontodate, 'Asia/Hong_Kong', 'GMT'),
  97.                                                               '%Y-%m-%dT%H:%i:%S+08:00'),
  98.                                        'EndTime', IF(re.exceptionfullday = 'Yes',
  99.                                                      2330,
  100.                                                      convert(re.exceptiontotime * 100, SIGNED))
  101.                                    )),
  102.                  ']')
  103.     FROM
  104.       hk_eatigo.restaurant_exceptions re
  105.     WHERE r.pkrestaurantid = re.fkrestaurantid AND re.exceptiondatetype = 1) AS data,
  106.     convert_tz((SELECT min(exceptiondateadded)
  107.               FROM hk_eatigo.restaurant_exceptions
  108.               WHERE r.pkrestaurantid = fkrestaurantid AND exceptiondatetype = 1
  109.               LIMIT 1), 'Asia/Hong_Kong',
  110.              'GMT')                                                         AS created_at,
  111.     convert_tz((SELECT max(exceptiondateadded)
  112.               FROM hk_eatigo.restaurant_exceptions
  113.               WHERE r.pkrestaurantid = fkrestaurantid AND exceptiondatetype = 1
  114.               LIMIT 1), 'Asia/Hong_Kong',
  115.              'GMT')                                                         AS updated_at
  116.   FROM hk_eatigo.restaurant r
  117.   WHERE (SELECT count(1)
  118.          FROM hk_eatigo.restaurant_exceptions re0
  119.          WHERE re0.fkrestaurantid = r.pkrestaurantid AND re0.exceptiondatetype = 1) > 0;
  120. REPLACE INTO e_restaurant.yield_calendar_omission (id, restaurant_id, version, data, created_at, updated_at)
  121.   SELECT
  122.     r.pkrestaurantid                                                          AS id,
  123.     r.pkrestaurantid                                                          AS resturant_id,
  124.     1                                                                         AS version,
  125.     (SELECT CONCAT('[', GROUP_CONCAT(JSON_OBJECT(
  126.                                        'StartDate', DATE_FORMAT(convert_tz(re.exceptionfromdate, 'Asia/Calcutta', 'GMT'),
  127.                                                                 '%Y-%m-%dT%H:%i:%S+05:30'),
  128.                                        'StartTime', IF(re.exceptionfullday = 'Yes',
  129.                                                        0,
  130.                                                        convert(re.exceptionfromtime * 100, SIGNED)),
  131.                                        'EndDate', DATE_FORMAT(convert_tz(re.exceptiontodate, 'Asia/Calcutta', 'GMT'),
  132.                                                               '%Y-%m-%dT%H:%i:%S+05:30'),
  133.                                        'EndTime', IF(re.exceptionfullday = 'Yes',
  134.                                                      2330,
  135.                                                      convert(re.exceptiontotime * 100, SIGNED))
  136.                                    )),
  137.                  ']')
  138.     FROM
  139.       in_eatigo.restaurant_exceptions re
  140.     WHERE r.pkrestaurantid = re.fkrestaurantid AND re.exceptiondatetype = 1) AS data,
  141.     convert_tz((SELECT min(exceptiondateadded)
  142.               FROM in_eatigo.restaurant_exceptions
  143.               WHERE r.pkrestaurantid = fkrestaurantid AND exceptiondatetype = 1
  144.               LIMIT 1), 'Asia/Calcutta',
  145.              'GMT')                                                         AS created_at,
  146.     convert_tz((SELECT max(exceptiondateadded)
  147.               FROM in_eatigo.restaurant_exceptions
  148.               WHERE r.pkrestaurantid = fkrestaurantid AND exceptiondatetype = 1
  149.               LIMIT 1), 'Asia/Calcutta',
  150.              'GMT')                                                         AS updated_at
  151.   FROM in_eatigo.restaurant r
  152.   WHERE (SELECT count(1)
  153.          FROM in_eatigo.restaurant_exceptions re0
  154.          WHERE re0.fkrestaurantid = r.pkrestaurantid AND re0.exceptiondatetype = 1) > 0;
  155. REPLACE INTO e_restaurant.yield_calendar_omission (id, restaurant_id, version, data, created_at, updated_at)
  156.   SELECT
  157.     r.pkrestaurantid                                                          AS id,
  158.     r.pkrestaurantid                                                          AS resturant_id,
  159.     1                                                                         AS version,
  160.     (SELECT CONCAT('[', GROUP_CONCAT(JSON_OBJECT(
  161.                                        'StartDate', DATE_FORMAT(convert_tz(re.exceptionfromdate, 'Asia/Manila', 'GMT'),
  162.                                                                 '%Y-%m-%dT%H:%i:%S+08:00'),
  163.                                        'StartTime', IF(re.exceptionfullday = 'Yes',
  164.                                                        0,
  165.                                                        convert(re.exceptionfromtime * 100, SIGNED)),
  166.                                        'EndDate', DATE_FORMAT(convert_tz(re.exceptiontodate, 'Asia/Manila', 'GMT'),
  167.                                                               '%Y-%m-%dT%H:%i:%S+08:00'),
  168.                                        'EndTime', IF(re.exceptionfullday = 'Yes',
  169.                                                      2330,
  170.                                                      convert(re.exceptiontotime * 100, SIGNED))
  171.                                    )),
  172.                  ']')
  173.     FROM
  174.       ph_eatigo.restaurant_exceptions re
  175.     WHERE r.pkrestaurantid = re.fkrestaurantid AND re.exceptiondatetype = 1) AS data,
  176.     convert_tz((SELECT min(exceptiondateadded)
  177.               FROM ph_eatigo.restaurant_exceptions
  178.               WHERE r.pkrestaurantid = fkrestaurantid AND exceptiondatetype = 1
  179.               LIMIT 1), 'Asia/Manila',
  180.              'GMT')                                                         AS created_at,
  181.     convert_tz((SELECT max(exceptiondateadded)
  182.               FROM ph_eatigo.restaurant_exceptions
  183.               WHERE r.pkrestaurantid = fkrestaurantid AND exceptiondatetype = 1
  184.               LIMIT 1), 'Asia/Manila',
  185.              'GMT')                                                         AS updated_at
  186.   FROM ph_eatigo.restaurant r
  187.   WHERE (SELECT count(1)
  188.          FROM ph_eatigo.restaurant_exceptions re0
  189.          WHERE re0.fkrestaurantid = r.pkrestaurantid AND re0.exceptiondatetype = 1) > 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement