CodeCommitsIssuesPull requestsActionsInsightsSecurity
6a344e6247412d45984e3a87c16691fe65646ca5

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

Setup/InstallSchema.php

61lines · modecode

1<?php
2
3namespace CloudFlare\Plugin\Setup;
4
5use Magento\Framework\Setup\InstallSchemaInterface;
6use Magento\Framework\Setup\ModuleContextInterface;
7use Magento\Framework\Setup\SchemaSetupInterface;
8use Magento\Framework\DB\Ddl\Table;
9
10class InstallSchema implements InstallSchemaInterface
11{
12 const CLOUDFLARE_DATA_TABLE_NAME = "cloudflare_data";
13 const CLOUDFLARE_DATA_TABLE_ID_COLUMN = "id";
14 const CLOUDFLARE_DATA_TABLE_KEY_COLUMN = "key";
15 const CLOUDFLARE_DATA_TABLE_VALUE_COLUMN = "value";
16
17 public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
18 {
19 $installer = $setup;
20 $installer->startSetup();
21
22 $tableName = $installer->getTable(self::CLOUDFLARE_DATA_TABLE_NAME);
23
24 if ($installer->getConnection()->isTableExists($tableName) != true) {
25 $table = $installer->getConnection()
26 ->newTable($tableName)
27 ->addColumn(
28 self::CLOUDFLARE_DATA_TABLE_ID_COLUMN,
29 Table::TYPE_INTEGER,
30 null,
31 [
32 'identity' => true,
33 'unsigned' => true,
34 'nullable' => false,
35 'primary' => true
36 ],
37 'ID'
38 )
39 ->addColumn(
40 self::CLOUDFLARE_DATA_TABLE_KEY_COLUMN,
41 Table::TYPE_TEXT,
42 null,
43 ['nullable' => false, 'default' => ''],
44 'Key'
45 )
46 ->addColumn(
47 self::CLOUDFLARE_DATA_TABLE_VALUE_COLUMN,
48 Table::TYPE_TEXT,
49 null,
50 ['nullable' => true, 'default' => ''],
51 'Value'
52 )
53 ->setComment('CloudFlare Key/Value Store.')
54 ->setOption('type', 'InnoDB')
55 ->setOption('charset', 'utf8');
56 $installer->getConnection()->createTable($table);
57 }
58
59 $installer->endSetup();
60 }
61}