PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/app/code/core/Mage/Core/sql/core_setup/mysql4-install-0.8.0.php

https://bitbucket.org/dnejedly/eaparts
PHP | 222 lines | 168 code | 29 blank | 25 comment | 0 complexity | d6fd9fe90c5ccba8092662a3a594cb44 MD5 | raw file
  1. <?php
  2. /**
  3. * Magento
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Open Software License (OSL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/osl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@magentocommerce.com so we can send you a copy immediately.
  14. *
  15. * DISCLAIMER
  16. *
  17. * Do not edit or add to this file if you wish to upgrade Magento to newer
  18. * versions in the future. If you wish to customize Magento for your
  19. * needs please refer to http://www.magentocommerce.com for more information.
  20. *
  21. * @category Mage
  22. * @package Mage_Core
  23. * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
  24. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  25. */
  26. $installer = $this;
  27. /* @var $installer Mage_Core_Model_Resource_Setup */
  28. $installer->startSetup();
  29. $installer->run("
  30. CREATE TABLE `{$installer->getTable('core_resource')}` (
  31. `code` varchar(50) NOT NULL default '',
  32. `version` varchar(50) NOT NULL default '',
  33. PRIMARY KEY (`code`)
  34. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Resource version registry';
  35. CREATE TABLE `{$installer->getTable('core_website')}` (
  36. `website_id` smallint(5) unsigned NOT NULL auto_increment,
  37. `code` varchar(32) NOT NULL default '',
  38. `name` varchar(64) NOT NULL default '',
  39. `sort_order` smallint(5) unsigned NOT NULL default '0',
  40. `default_group_id` smallint(5) unsigned NOT NULL default '0',
  41. PRIMARY KEY (`website_id`),
  42. UNIQUE KEY `code` (`code`),
  43. KEY `sort_order` (`sort_order`),
  44. KEY `default_group_id` (`default_group_id`)
  45. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Websites';
  46. INSERT INTO `{$installer->getTable('core_website')}` VALUES
  47. (0, 'admin', 'Admin', 0, 0),
  48. (1, 'base', 'Main Website', 0, 1);
  49. -- DROP TABLE IF EXISTS `{$installer->getTable('core_store_group')}`;
  50. CREATE TABLE `{$installer->getTable('core_store_group')}` (
  51. `group_id` smallint(5) unsigned NOT NULL auto_increment,
  52. `website_id` smallint(5) unsigned NOT NULL default '0',
  53. `name` varchar(32) NOT NULL default '',
  54. `root_category_id` int(10) unsigned NOT NULL default '0',
  55. `default_store_id` smallint(5) unsigned NOT NULL default '0',
  56. PRIMARY KEY (`group_id`),
  57. KEY `FK_STORE_GROUP_WEBSITE` (`website_id`),
  58. KEY `default_store_id` (`default_store_id`)
  59. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  60. INSERT INTO `{$installer->getTable('core_store_group')}` VALUES
  61. (0, 0, 'Default', 0, 0),
  62. (1, 1, 'Main Website Store', 2, 1);
  63. -- DROP TABLE IF EXISTS `{$installer->getTable('core_store')}`;
  64. CREATE TABLE `{$installer->getTable('core_store')}` (
  65. `store_id` smallint(5) unsigned NOT NULL auto_increment,
  66. `code` varchar(32) NOT NULL default '',
  67. `website_id` smallint(5) unsigned default '0',
  68. `group_id` smallint(5) unsigned NOT NULL default '0',
  69. `name` varchar(32) NOT NULL default '',
  70. `sort_order` smallint(5) unsigned NOT NULL default '0',
  71. `is_active` tinyint(1) unsigned NOT NULL default '0',
  72. PRIMARY KEY (`store_id`),
  73. UNIQUE KEY `code` (`code`),
  74. KEY `FK_STORE_WEBSITE` (`website_id`),
  75. KEY `is_active` (`is_active`,`sort_order`),
  76. KEY `FK_STORE_GROUP` (`group_id`)
  77. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Stores';
  78. INSERT INTO `{$installer->getTable('core_store')}` VALUES
  79. (0, 'admin', 0, 0, 'Admin', 0, 1),
  80. (1, 'default', 1, 1, 'Default Store View', 0, 1);
  81. CREATE TABLE `{$installer->getTable('core_config_data')}` (
  82. `config_id` int(10) unsigned NOT NULL auto_increment,
  83. `scope` enum('default','websites','stores','config') NOT NULL default 'default',
  84. `scope_id` int(11) NOT NULL default '0',
  85. `path` varchar(255) NOT NULL default 'general',
  86. `value` text NOT NULL,
  87. PRIMARY KEY (`config_id`),
  88. UNIQUE KEY `config_scope` (`scope`,`scope_id`,`path`)
  89. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  90. CREATE TABLE `{$installer->getTable('core_email_template')}` (
  91. `template_id` int(7) unsigned NOT NULL auto_increment,
  92. `template_code` varchar(150) default NULL,
  93. `template_text` text,
  94. `template_type` int(3) unsigned default NULL,
  95. `template_subject` varchar(200) default NULL,
  96. `template_sender_name` varchar(200) default NULL,
  97. `template_sender_email` varchar(200) character set latin1 collate latin1_general_ci default NULL,
  98. `added_at` datetime default NULL,
  99. `modified_at` datetime default NULL,
  100. PRIMARY KEY (`template_id`),
  101. UNIQUE KEY `template_code` (`template_code`),
  102. KEY `added_at` (`added_at`),
  103. KEY `modified_at` (`modified_at`)
  104. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Email templates';
  105. CREATE TABLE `{$installer->getTable('core_layout_update')}` (
  106. `layout_update_id` int(10) unsigned NOT NULL auto_increment,
  107. `handle` varchar(255) default NULL,
  108. `xml` text,
  109. PRIMARY KEY (`layout_update_id`),
  110. KEY `handle` (`handle`)
  111. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  112. CREATE TABLE `{$installer->getTable('core_layout_link')}` (
  113. `layout_link_id` int(10) unsigned NOT NULL auto_increment,
  114. `store_id` smallint(5) unsigned NOT NULL default '0',
  115. `package` varchar(64) NOT NULL default '',
  116. `theme` varchar(64) NOT NULL default '',
  117. `layout_update_id` int(10) unsigned NOT NULL default '0',
  118. PRIMARY KEY (`layout_link_id`),
  119. UNIQUE KEY `store_id` (`store_id`,`package`,`theme`,`layout_update_id`),
  120. KEY `FK_core_layout_link_update` (`layout_update_id`)
  121. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  122. CREATE TABLE `{$installer->getTable('core_session')}` (
  123. `session_id` varchar(255) NOT NULL default '',
  124. `website_id` smallint(5) unsigned default NULL,
  125. `session_expires` int(10) unsigned NOT NULL default '0',
  126. `session_data` text NOT NULL,
  127. PRIMARY KEY (`session_id`),
  128. KEY `FK_SESSION_WEBSITE` (`website_id`)
  129. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Session data store';
  130. CREATE TABLE `{$installer->getTable('core_translate')}` (
  131. `key_id` int(10) unsigned NOT NULL auto_increment,
  132. `string` varchar(255) NOT NULL default '',
  133. `store_id` smallint(5) unsigned NOT NULL default '0',
  134. `translate` varchar(255) NOT NULL default '',
  135. `locale` varchar(20) NOT NULL default 'en_US',
  136. PRIMARY KEY (`key_id`),
  137. UNIQUE KEY `IDX_CODE` (`store_id`,`locale`,`string`),
  138. KEY `FK_CORE_TRANSLATE_STORE` (`store_id`)
  139. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Translation data';
  140. CREATE TABLE `{$installer->getTable('core_url_rewrite')}` (
  141. `url_rewrite_id` int(10) unsigned NOT NULL auto_increment,
  142. `store_id` smallint(5) unsigned NOT NULL default '0',
  143. `id_path` varchar(255) NOT NULL default '',
  144. `request_path` varchar(255) NOT NULL default '',
  145. `target_path` varchar(255) NOT NULL default '',
  146. `options` varchar(255) NOT NULL default '',
  147. `type` int(1) NOT NULL default '0',
  148. `description` varchar(255) default NULL,
  149. PRIMARY KEY (`url_rewrite_id`),
  150. UNIQUE KEY `id_path` (`id_path`,`store_id`),
  151. UNIQUE KEY `request_path` (`request_path`,`store_id`),
  152. KEY `target_path` (`target_path`,`store_id`),
  153. KEY `store_id` (`store_id`)
  154. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  155. CREATE TABLE `{$installer->getTable('core_url_rewrite_tag')}` (
  156. `url_rewrite_tag_id` int(10) unsigned NOT NULL auto_increment,
  157. `url_rewrite_id` int(10) unsigned NOT NULL default '0',
  158. `tag` varchar(255) default NULL,
  159. PRIMARY KEY (`url_rewrite_tag_id`),
  160. UNIQUE KEY `tag` (`tag`,`url_rewrite_id`),
  161. KEY `url_rewrite_id` (`url_rewrite_id`)
  162. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  163. CREATE TABLE `{$installer->getTable('design_change')}` (
  164. `design_change_id` int(11) NOT NULL auto_increment,
  165. `store_id` smallint(5) unsigned NOT NULL default '0',
  166. `design` varchar(255) NOT NULL default '',
  167. `date_from` date NOT NULL default '0000-00-00',
  168. `date_to` date NOT NULL default '0000-00-00',
  169. PRIMARY KEY (`design_change_id`),
  170. KEY `FK_DESIGN_CHANGE_STORE` (`store_id`)
  171. ) ENGINE=InnoDB DEFAULT CHARSET=utf8
  172. ");
  173. $installer->run("
  174. ALTER TABLE `{$installer->getTable('core_store_group')}`
  175. ADD CONSTRAINT `FK_STORE_GROUP_WEBSITE` FOREIGN KEY (`website_id`) REFERENCES `{$installer->getTable('core_website')}` (`website_id`) ON DELETE CASCADE ON UPDATE CASCADE;
  176. ALTER TABLE `{$installer->getTable('core_store')}`
  177. ADD CONSTRAINT `FK_STORE_GROUP_STORE` FOREIGN KEY (`group_id`) REFERENCES `{$installer->getTable('core_store_group')}` (`group_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  178. ADD CONSTRAINT `FK_STORE_WEBSITE` FOREIGN KEY (`website_id`) REFERENCES `{$installer->getTable('core_website')}` (`website_id`) ON DELETE CASCADE ON UPDATE CASCADE;
  179. ALTER TABLE `{$installer->getTable('core_layout_link')}`
  180. ADD CONSTRAINT `FK_CORE_LAYOUT_LINK_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$installer->getTable('core_store')}` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  181. ADD CONSTRAINT `FK_CORE_LAYOUT_LINK_UPDATE` FOREIGN KEY (`layout_update_id`) REFERENCES `{$installer->getTable('core_layout_update')}` (`layout_update_id`) ON DELETE CASCADE ON UPDATE CASCADE;
  182. ALTER TABLE `{$installer->getTable('core_session')}`
  183. ADD CONSTRAINT `FK_SESSION_WEBSITE` FOREIGN KEY (`website_id`) REFERENCES `{$installer->getTable('core_website')}` (`website_id`) ON DELETE CASCADE ON UPDATE CASCADE;
  184. ALTER TABLE `{$installer->getTable('core_translate')}`
  185. ADD CONSTRAINT `FK_CORE_TRANSLATE_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$installer->getTable('core_store')}` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE;
  186. ALTER TABLE `{$installer->getTable('core_url_rewrite')}`
  187. ADD CONSTRAINT `FK_CORE_URL_REWRITE_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$installer->getTable('core_store')}` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE;
  188. ALTER TABLE `{$installer->getTable('core_url_rewrite_tag')}`
  189. ADD CONSTRAINT `FK_CORE_URL_REWRITE_TAG_URL_REWRITE` FOREIGN KEY (`url_rewrite_id`) REFERENCES `{$installer->getTable('core_url_rewrite')}` (`url_rewrite_id`) ON DELETE CASCADE ON UPDATE CASCADE;
  190. ALTER TABLE `{$installer->getTable('design_change')}`
  191. ADD CONSTRAINT `FK_DESIGN_CHANGE_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$installer->getTable('core_store')}` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE;
  192. ");
  193. $installer->endSetup();