7.9-update.sql 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. SET NAMES utf8;
  2. SET time_zone = '+00:00';
  3. SET foreign_key_checks = 0;
  4. SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
  5. CREATE TABLE `{%TABLE_PREFIX%}newsletters_subscribers` (
  6. `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  7. `user_id` INT(11) NULL,
  8. `email` VARCHAR(255) NOT NULL,
  9. `created_at` DATETIME NOT NULL,
  10. FOREIGN KEY (`user_id`) REFERENCES `{%TABLE_PREFIX%}users` (`id`)
  11. ON DELETE CASCADE
  12. )
  13. ENGINE = 'InnoDB'
  14. COLLATE 'utf8_general_ci';
  15. ALTER TABLE `{%TABLE_PREFIX%}newsletters_recipients`
  16. ADD `subscriber_id` INT(11) NULL
  17. AFTER `newsletter_id`;
  18. ALTER TABLE `{%TABLE_PREFIX%}newsletters_recipients`
  19. ADD FOREIGN KEY (`subscriber_id`) REFERENCES `{%TABLE_PREFIX%}newsletters_subscribers` (`id`)
  20. ON DELETE CASCADE;
  21. -- workaround because its complicated to remove the user_id foreign key, so wed rather set the user_id field as null from now on
  22. ALTER TABLE `{%TABLE_PREFIX%}newsletters_recipients`
  23. CHANGE `user_id` `user_id` INT(11) NULL
  24. AFTER `subscriber_id`;
  25. -- transfer subscribers to new table
  26. INSERT INTO `{%TABLE_PREFIX%}newsletters_subscribers`
  27. (`user_id`, `email`, `created_at`)
  28. SELECT
  29. `id`,
  30. `email`,
  31. NOW()
  32. FROM `{%TABLE_PREFIX%}users`
  33. WHERE `newsletter_subscription` = '1';
  34. INSERT INTO `{%TABLE_PREFIX%}settings`
  35. (`name`, `value`) VALUES
  36. ('newsletter_subscription_box', '');
  37. ALTER TABLE `{%TABLE_PREFIX%}users`
  38. CHANGE `birthdate` `birthdate` DATE NULL
  39. AFTER `salt`;
  40. ALTER TABLE `{%TABLE_PREFIX%}users`
  41. CHANGE `last_login` `last_login` DATETIME NULL
  42. AFTER `role`;
  43. CREATE TABLE `{%TABLE_PREFIX%}cache` (
  44. `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  45. `name` VARCHAR(255) NOT NULL,
  46. `type` VARCHAR(50) NOT NULL,
  47. `data` TEXT NOT NULL,
  48. `created_at` DATETIME NOT NULL
  49. )
  50. ENGINE = 'InnoDB'
  51. COLLATE 'utf8_general_ci';
  52. ALTER TABLE `{%TABLE_PREFIX%}cache`
  53. ADD INDEX `name_type` (`name`, `type`),
  54. ADD INDEX `created_at` (`created_at`);
  55. ALTER TABLE `{%TABLE_PREFIX%}categories`
  56. ADD `adult` TINYINT(4) NOT NULL
  57. AFTER `custom_fees`;
  58. INSERT INTO `{%TABLE_PREFIX%}settings`
  59. (`name`, `value`) VALUES
  60. ('enable_adult_categories', ''),
  61. ('adult_categories_splash_page', ''),
  62. ('adult_categories_splash_page_content', '');
  63. INSERT INTO `{%TABLE_PREFIX%}settings`
  64. (`name`, `value`) VALUES
  65. ('lazy_load_images', '1');
  66. ALTER TABLE `{%TABLE_PREFIX%}users`
  67. ADD `ip_address` VARCHAR(50)
  68. COLLATE 'utf8_general_ci' NOT NULL
  69. AFTER `mail_activated`;