InstallSchema.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. namespace Smartwave\Dailydeals\Setup;
  3. class InstallSchema implements \Magento\Framework\Setup\InstallSchemaInterface
  4. {
  5. /**
  6. * install tables
  7. *
  8. * @param \Magento\Framework\Setup\SchemaSetupInterface $setup
  9. * @param \Magento\Framework\Setup\ModuleContextInterface $context
  10. * @return void
  11. * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  12. */
  13. public function install(\Magento\Framework\Setup\SchemaSetupInterface $setup, \Magento\Framework\Setup\ModuleContextInterface $context)
  14. {
  15. $installer = $setup;
  16. $installer->startSetup();
  17. if (!$installer->tableExists('sw_dailydeals_dailydeal')) {
  18. $table = $installer->getConnection()->newTable(
  19. $installer->getTable('sw_dailydeals_dailydeal')
  20. )
  21. ->addColumn(
  22. 'dailydeal_id',
  23. \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
  24. null,
  25. [
  26. 'identity' => true,
  27. 'nullable' => false,
  28. 'primary' => true,
  29. 'unsigned' => true,
  30. ],
  31. 'Dailydeal ID'
  32. )
  33. ->addColumn(
  34. 'sw_product_sku',
  35. \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
  36. 255,
  37. [],
  38. 'Dailydeal Product Sku'
  39. )
  40. ->addColumn(
  41. 'sw_product_price',
  42. \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL,
  43. '12,4',
  44. [],
  45. 'Dailydeal Product Price'
  46. )
  47. ->addColumn(
  48. 'sw_deal_enable',
  49. \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
  50. 1,
  51. [],
  52. 'Dailydeal Enable Deal'
  53. )
  54. ->addColumn(
  55. 'sw_discount_type',
  56. \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
  57. null,
  58. [],
  59. 'Dailydeal Discount Type'
  60. )
  61. ->addColumn(
  62. 'sw_discount_amount',
  63. \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL,
  64. '12,4',
  65. [],
  66. 'Dailydeal Discount Amount'
  67. )
  68. ->addColumn(
  69. 'sw_date_from',
  70. \Magento\Framework\DB\Ddl\Table::TYPE_DATETIME,
  71. null,
  72. [],
  73. 'Dailydeal Date From'
  74. )
  75. ->addColumn(
  76. 'sw_date_to',
  77. \Magento\Framework\DB\Ddl\Table::TYPE_DATETIME,
  78. null,
  79. [],
  80. 'Dailydeal Date To'
  81. )
  82. ->addColumn(
  83. 'created_at',
  84. \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
  85. null,
  86. [],
  87. 'Dailydeal Created At'
  88. )
  89. ->addColumn(
  90. 'updated_at',
  91. \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
  92. null,
  93. [],
  94. 'Dailydeal Updated At'
  95. )
  96. ->setComment('Dailydeal Table');
  97. $installer->getConnection()->createTable($table);
  98. $installer->getConnection()->addIndex(
  99. $installer->getTable('sw_dailydeals_dailydeal'),
  100. $setup->getIdxName(
  101. $installer->getTable('sw_dailydeals_dailydeal'),
  102. ['sw_product_sku'],
  103. \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT
  104. ),
  105. ['sw_product_sku'],
  106. \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT
  107. );
  108. }
  109. $installer->endSetup();
  110. }
  111. }