InstallSchema.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /**
  3. * This file is part of the Klarna KP module
  4. *
  5. * (c) Klarna Bank AB (publ)
  6. *
  7. * For the full copyright and license information, please view the NOTICE
  8. * and LICENSE files that were distributed with this source code.
  9. */
  10. namespace Klarna\Kp\Setup;
  11. use Magento\Framework\DB\Ddl\Table;
  12. use Magento\Framework\Setup\InstallSchemaInterface;
  13. use Magento\Framework\Setup\ModuleContextInterface;
  14. use Magento\Framework\Setup\SchemaSetupInterface;
  15. class InstallSchema implements InstallSchemaInterface
  16. {
  17. /**
  18. * @param SchemaSetupInterface $setup
  19. * @param ModuleContextInterface $context
  20. * @throws \Zend_Db_Exception
  21. * @SuppressWarnings(PMD.UnusedFormalParameter)
  22. */
  23. public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
  24. {
  25. $installer = $setup;
  26. $installer->startSetup();
  27. /**
  28. * Create table 'klarna_payments_quote'
  29. */
  30. $table = $installer->getConnection()
  31. ->newTable($installer->getTable('klarna_payments_quote'))
  32. ->addColumn(
  33. 'payments_quote_id',
  34. Table::TYPE_INTEGER,
  35. null,
  36. [
  37. 'identity' => true,
  38. 'unsigned' => true,
  39. 'nullable' => false,
  40. 'primary' => true,
  41. ],
  42. 'Payments Id'
  43. )
  44. ->addColumn(
  45. 'session_id',
  46. Table::TYPE_TEXT,
  47. 255,
  48. [],
  49. 'Klarna Session Id'
  50. )
  51. ->addColumn(
  52. 'client_token',
  53. Table::TYPE_TEXT,
  54. '64k',
  55. [],
  56. 'Klarna Client Token'
  57. )
  58. ->addColumn(
  59. 'authorization_token',
  60. Table::TYPE_TEXT,
  61. 255,
  62. [],
  63. 'Authorization Token'
  64. )
  65. ->addColumn(
  66. 'is_active',
  67. Table::TYPE_SMALLINT,
  68. null,
  69. [
  70. 'nullable' => false,
  71. 'default' => '0',
  72. ],
  73. 'Is Active'
  74. )
  75. ->addColumn(
  76. 'quote_id',
  77. Table::TYPE_INTEGER,
  78. null,
  79. [
  80. 'unsigned' => true,
  81. 'nullable' => false,
  82. ],
  83. 'Quote Id'
  84. )
  85. ->addForeignKey(
  86. $installer->getFkName(
  87. 'klarna_payments_quote',
  88. 'quote_id',
  89. 'quote',
  90. 'entity_id'
  91. ),
  92. 'quote_id',
  93. $installer->getTable('quote'),
  94. 'entity_id',
  95. Table::ACTION_CASCADE
  96. )
  97. ->setComment('Klarna Payments Quote');
  98. $installer->getConnection()->createTable($table);
  99. $installer->endSetup();
  100. }
  101. }