├── .github
└── FUNDING.yml
├── Api
└── SchemaSetupBuilderInterface.php
├── Block
├── Adminhtml
│ ├── Retriever.php
│ └── Retriever
│ │ ├── Edit.php
│ │ └── Edit
│ │ ├── Form.php
│ │ ├── Tab
│ │ ├── Infos.php
│ │ └── Tables.php
│ │ └── Tabs.php
├── InstallSchema.php
└── InstallSchema
│ ├── TableDeclaration.php
│ └── TableDeclaration
│ ├── ColumnDeclaration.php
│ ├── ForeignKeyDeclaration.php
│ └── IndexDeclaration.php
├── Console
└── Command
│ └── InstallSchemaGeneratorCommand.php
├── Controller
└── Adminhtml
│ └── Index
│ ├── Index.php
│ └── Retriever.php
├── LICENSE
├── Model
├── DB
│ └── SchemaRetriever.php
└── SchemaSetupBuilder.php
├── README.md
├── composer.json
├── etc
├── acl.xml
├── adminhtml
│ ├── menu.xml
│ └── routes.xml
├── di.xml
└── module.xml
├── registration.php
└── view
├── adminhtml
├── layout
│ └── install_schema_generator_index_index.xml
└── templates
│ ├── install-schema.phtml
│ └── install-schema
│ ├── table-declaration.phtml
│ └── table-declaration
│ ├── column-declaration.phtml
│ ├── foreign-key-declaration.phtml
│ └── index-declaration.phtml
└── global
└── templates
├── install-schema.phtml
└── install-schema
├── table-declaration.phtml
└── table-declaration
├── column-declaration.phtml
├── foreign-key-declaration.phtml
└── index-declaration.phtml
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | #github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: thomas_klein # Replace with a single Patreon username
5 | #open_collective: # Replace with a single Open Collective username
6 | #ko_fi: # Replace with a single Ko-fi username
7 | #tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | #community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | #liberapay: # Replace with a single Liberapay username
10 | #issuehunt: # Replace with a single IssueHunt username
11 | #otechie: # Replace with a single Otechie username
12 | #custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
13 |
--------------------------------------------------------------------------------
/Api/SchemaSetupBuilderInterface.php:
--------------------------------------------------------------------------------
1 | _blockGroup = 'Blackbird_InstallSchemaGenerator';
28 | $this->_controller = 'adminhtml_retriever';
29 | parent::_construct();
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Block/Adminhtml/Retriever/Edit.php:
--------------------------------------------------------------------------------
1 | _blockGroup = 'Blackbird_InstallSchemaGenerator';
31 | $this->_controller = 'adminhtml_retriever';
32 |
33 | parent::_construct();
34 |
35 | $this->removeButton('save');
36 | $this->removeButton('reset');
37 | $this->removeButton('back');
38 | $this->addButton(
39 | 'retrieve',
40 | [
41 | 'label' => __('Generate and download file'),
42 | 'class' => 'retrieve primary',
43 | 'data_attribute' => [
44 | 'mage-init' => ['button' => ['event' => 'save', 'target' => '#edit_form']],
45 | ]
46 | ],
47 | 1
48 | );
49 | }
50 |
51 | /**
52 | * Getter for form header text
53 | *
54 | * @return \Magento\Framework\Phrase
55 | */
56 | public function getHeaderText()
57 | {
58 | return __('Retrieve Install Schema');
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/Block/Adminhtml/Retriever/Edit/Form.php:
--------------------------------------------------------------------------------
1 | _formFactory->create(
29 | [
30 | 'data' => [
31 | 'id' => 'edit_form',
32 | 'action' => $this->getUrl('*/*/retriever', ['_current' => true]),
33 | 'method' => 'post',
34 | ],
35 | ]
36 | );
37 | $form->setUseContainer(true);
38 | $this->setForm($form);
39 |
40 | return parent::_prepareForm();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Block/Adminhtml/Retriever/Edit/Tab/Infos.php:
--------------------------------------------------------------------------------
1 | _formFactory->create();
65 | $form->setHtmlIdPrefix('isg_');
66 |
67 | $fieldset = $form->addFieldset(
68 | 'infos_fieldset',
69 | ['legend' => __('Informations about your namespace\'s module')]
70 | );
71 |
72 | $fieldset->addField(
73 | 'vendor',
74 | 'text',
75 | [
76 | 'name' => 'vendor',
77 | 'label' => __("Vendor's Name"),
78 | 'title' => __("Vendor's Name"),
79 | 'note' => __("Vendor's name is generally the name of the company and is the first element of your namespace: <Vendor>\<Module>")
80 | ]
81 | );
82 |
83 | $fieldset->addField(
84 | 'module',
85 | 'text',
86 | [
87 | 'name' => 'module',
88 | 'label' => __('Module Name'),
89 | 'title' => __('Module Name'),
90 | 'note' => __("It's the name of your module : <Vendor>\<Module>")
91 | ]
92 | );
93 |
94 | $data = [
95 | 'vendor' => 'Vendor',
96 | 'module' => 'Area'
97 | ];
98 |
99 | $this->setValues($data);
100 | $this->setForm($form);
101 |
102 | return parent::_prepareForm();
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/Block/Adminhtml/Retriever/Edit/Tab/Tables.php:
--------------------------------------------------------------------------------
1 | schemaSource = $schemaRetriever;
50 | parent::__construct($context, $registry, $formFactory, $data);
51 | }
52 |
53 | /**
54 | * @return string
55 | */
56 | public function getTabLabel()
57 | {
58 | return __('Tables');
59 | }
60 |
61 | /**
62 | * @return string
63 | */
64 | public function getTabTitle()
65 | {
66 | return __('Tables');
67 | }
68 |
69 | /**
70 | * @return boolean
71 | */
72 | public function canShowTab()
73 | {
74 | return true;
75 | }
76 |
77 | /**
78 | * @return boolean
79 | */
80 | public function isHidden()
81 | {
82 | return false;
83 | }
84 |
85 | /**
86 | * {@inheritdoc}
87 | */
88 | public function _prepareForm()
89 | {
90 | /** @var \Magento\Framework\Data\Form $form */
91 | $form = $this->_formFactory->create();
92 | $form->setHtmlIdPrefix('isg_');
93 |
94 | $fieldset = $form->addFieldset(
95 | 'tables_fieldset',
96 | ['legend' => __('Generate InstallSchema.php file from table(s)')]
97 | );
98 |
99 | $fieldset->addField(
100 | 'tables',
101 | 'multiselect',
102 | [
103 | 'name' => 'tables',
104 | 'label' => __('Tables'),
105 | 'title' => __('Tables'),
106 | 'note' => __('Select the table(s) to generate the InstallSchema.php file.'),
107 | 'required' => true,
108 | 'values' => $this->schemaSource->getTablesOptions()
109 | ]
110 | );
111 |
112 | $this->setForm($form);
113 |
114 | return parent::_prepareForm();
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/Block/Adminhtml/Retriever/Edit/Tabs.php:
--------------------------------------------------------------------------------
1 | setId('installschemagenerator_retriever_tabs');
29 | $this->setDestElementId('edit_form');
30 | $this->setTitle(__('Settings'));
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Block/InstallSchema.php:
--------------------------------------------------------------------------------
1 | toHtml();
39 | }
40 |
41 | /**
42 | * Retrieve the table definition
43 | *
44 | * @param array $tableName
45 | * @param array $columns
46 | * @return string
47 | */
48 | public function getTableDeclarationHtml($tableName, array $columns)
49 | {
50 | return $this->getLayout()
51 | ->createBlock(TableDeclaration::class)
52 | ->setTableName($tableName)
53 | ->setColumns($columns)
54 | ->toHtml();
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/Block/InstallSchema/TableDeclaration.php:
--------------------------------------------------------------------------------
1 | getLayout()
42 | ->createBlock(ColumnDeclaration::class)
43 | ->setColumnData($column)
44 | ->toHtml();
45 | }
46 |
47 | /**
48 | * Retrieve the index definition
49 | *
50 | * @param array $columns
51 | * @return string
52 | */
53 | public function getIndexDeclarationHtml(array $columns)
54 | {
55 | return $this->getLayout()
56 | ->createBlock(IndexDeclaration::class)
57 | ->setTableName($this->getTableName())
58 | ->setColumns($columns)
59 | ->toHtml();
60 | }
61 |
62 | /**
63 | * Retrieve the foreign key definition
64 | *
65 | * @param string $columnName
66 | * @param array $constraint
67 | * @return string
68 | */
69 | public function getForeignKeyDeclarationHtml($columnName, array $constraint)
70 | {
71 | return $this->getLayout()
72 | ->createBlock(ForeignKeyDeclaration::class)
73 | ->setTableName($this->getTableName())
74 | ->setColumnName($columnName)
75 | ->setConstraintData($constraint)
76 | ->toHtml();
77 | }
78 |
79 | /**
80 | * Retrieve the table comment
81 | *
82 | * @return string
83 | */
84 | public function getComment()
85 | {
86 | $column = $this->getColumn();
87 | $comment = $column['TABLE_COMMENT'];
88 |
89 | if (empty($comment)) {
90 | $comment = $column['TABLE_NAME'];
91 | }
92 |
93 | return $comment;
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/Block/InstallSchema/TableDeclaration/ColumnDeclaration.php:
--------------------------------------------------------------------------------
1 | getColumnData();
38 |
39 | return $column['COLUMN_NAME'];
40 | }
41 |
42 | /**
43 | * Retrieve the column type
44 | *
45 | * @todo refactor
46 | * @return string
47 | */
48 | public function getColumnType()
49 | {
50 | $typeSize = $this->getTypeAndSize();
51 |
52 | return $typeSize['type'];
53 | }
54 |
55 | /**
56 | * Retrieve the column size
57 | *
58 | * @todo refactor
59 | * @return string
60 | */
61 | public function getColumnSize()
62 | {
63 | $typeSize = $this->getTypeAndSize();
64 |
65 | return $typeSize['size'];
66 | }
67 |
68 | /**
69 | * Retrieve the column unsigned
70 | *
71 | * @todo refactor
72 | * @return string
73 | */
74 | public function getColumnUnsigned()
75 | {
76 | $typeSize = $this->getTypeAndSize();
77 |
78 | return $typeSize['unsigned'];
79 | }
80 |
81 | /**
82 | * Retrieve the column comment
83 | *
84 | * @return string
85 | */
86 | public function getColumnComment()
87 | {
88 | $column = $this->getColumnData();
89 |
90 | return $column['COLUMN_COMMENT'] ?: 'null';
91 | }
92 |
93 | /**
94 | * Retrieve the column precision
95 | *
96 | * @return string
97 | */
98 | public function getColumnPrecision()
99 | {
100 | $column = $this->getColumnData();
101 | $precision = null;
102 |
103 | if (!is_null($column['NUMERIC_PRECISION'])) {
104 | $precision = $column['NUMERIC_PRECISION'];
105 | } elseif (!is_null($column['DATETIME_PRECISION'])) {
106 | $precision = $column['DATETIME_PRECISION'];
107 | }
108 |
109 | return $precision;
110 | }
111 |
112 | /**
113 | * Retrieve the column options
114 | *
115 | * @return array
116 | */
117 | public function getOptions()
118 | {
119 | $column = $this->getColumnData();
120 | $options = [];
121 |
122 | if (!empty($column['COLUMN_DEFAULT']) || $column['COLUMN_DEFAULT'] == '0') {
123 | $options['default'] = $column['COLUMN_DEFAULT'];
124 | }
125 | if ($column['IS_NULLABLE'] === 'NO') {
126 | $options['nullable'] = 'false';
127 | } else {
128 | $options['nullable'] = 'true';
129 | }
130 | if (!empty($column['NUMERIC_SCALE'])) {
131 | $options['scale'] = $column['NUMERIC_SCALE'];
132 | }
133 | if (!empty($this->getColumnPrecision())) {
134 | $options['precision'] = $this->getColumnPrecision();
135 | }
136 | if ($this->getColumnUnsigned()) {
137 | $options['unsigned'] = 'true';
138 | }
139 | if (!empty($column['EXTRA'])) {
140 | if (in_array($column['EXTRA'], ['auto_increment', 'on update CURRENT_TIMESTAMP'])) {
141 | $options[$column['EXTRA']] = 'true';
142 | }
143 | }
144 | if (!empty($column['COLUMN_KEY'])) {
145 | // PRI, (UNI, MUL are processed in addIndex method in Magento 2)
146 | if ($column['COLUMN_KEY'] === 'PRI') {
147 | $options['primary'] = 'true';
148 | }
149 | }
150 |
151 | return $options;
152 | }
153 |
154 | /**
155 | * Return the type and the size of the field
156 | *
157 | * @return array
158 | */
159 | private function getTypeAndSize()
160 | {
161 | $column = $this->getColumnData();
162 | $type = $column['COLUMN_TYPE'];
163 | $unsigned = stripos($type, 'unsigned') === false ? '' : 'true';
164 |
165 | $matches = [];
166 | preg_match('#(.*)[(](.+)[)].*#', $type, $matches);
167 |
168 | $match = (!empty($matches[1])) ? strtolower($matches[1]) : $type;
169 | $size = (!empty($matches[2])) ? $matches[2] : 'null';
170 |
171 | // Formalize the type for magento 2
172 | $type = $this->getRealType($match);
173 | $type = $type['type'];
174 | $size = (isset($type['size'])) ? $type['size'] : $size;
175 |
176 | return ['type' => $type, 'size' => $size, 'unsigned' => $unsigned];
177 | }
178 |
179 | /**
180 | * Returns the type and size by mysql type
181 | *
182 | * @param string $type
183 | * @return array
184 | */
185 | private function getRealType($type)
186 | {
187 | $result = ['type' => strtoupper($type)];
188 |
189 | $types = [
190 | 'char' => [
191 | 'type' => 'TEXT',
192 | ],
193 | 'varchar' => [
194 | 'type' => 'TEXT',
195 | ],
196 | 'text' => [
197 | 'type' => 'TEXT',
198 | 'size' => '16000',
199 | ],
200 | 'tinytext' => [
201 | 'type' => 'TEXT',
202 | 'size' => '255',
203 | ],
204 | 'mediumtext' => [
205 | 'type' => 'TEXT',
206 | 'size' => '16000000',
207 | ],
208 | 'longtext' => [
209 | 'type' => 'TEXT',
210 | 'size' => '16000000000',
211 | ],
212 | 'int' => [
213 | 'type' => 'INTEGER',
214 | ],
215 | 'tinyint' => [
216 | 'type' => 'SMALLINT',
217 | ],
218 | 'mediumint' => [
219 | 'type' => 'INTEGER',
220 | ],
221 | 'double' => [
222 | 'type' => 'FLOAT',
223 | ],
224 | 'real' => [
225 | 'type' => 'FLOAT',
226 | ],
227 | 'time' => [
228 | 'type' => 'TIMESTAMP',
229 | ],
230 | 'tinyblob' => [
231 | 'type' => 'BLOB',
232 | ],
233 | 'mediumblob' => [
234 | 'type' => 'BLOB',
235 | ],
236 | 'longblob' => [
237 | 'type' => 'BLOB',
238 | ],
239 | 'binary' => [
240 | 'type' => 'VARBINARY',
241 | ]
242 | ];
243 |
244 | if (isset($types[$type])) {
245 | $result = $types[$type];
246 | }
247 |
248 | return $result;
249 | }
250 | }
251 |
--------------------------------------------------------------------------------
/Block/InstallSchema/TableDeclaration/ForeignKeyDeclaration.php:
--------------------------------------------------------------------------------
1 | getDeleteRule()) &&
38 | $this->getFkName() &&
39 | $this->getRefFkTableName() &&
40 | $this->getRefFkColumnName());
41 | }
42 |
43 | /**
44 | * Retrieve the constraint delete rule
45 | *
46 | * @return string
47 | */
48 | public function getDeleteRule()
49 | {
50 | $constraint = $this->getConstraintData();
51 |
52 | return str_replace(' ', '_', strtoupper($constraint['DELETE_RULE']));
53 | }
54 |
55 | /**
56 | * Retrieve the foreign key name
57 | *
58 | * @return string
59 | */
60 | public function getFkName()
61 | {
62 | $constraint = $this->getConstraintData();
63 |
64 | return $constraint['CONSTRAINT_NAME'];
65 | }
66 |
67 | /**
68 | * Retrieve the foreign key table name
69 | *
70 | * @return string
71 | */
72 | public function getFkTableName()
73 | {
74 | return $this->getTableName();
75 | }
76 |
77 | /**
78 | * Retrieve the foreign key column name
79 | *
80 | * @return string
81 | */
82 | public function getFkColumnName()
83 | {
84 | return $this->getColumnName();
85 | }
86 |
87 | /**
88 | * Retrieve the referenced table name
89 | *
90 | * @return string
91 | */
92 | public function getRefFkTableName()
93 | {
94 | $constraint = $this->getConstraintData();
95 |
96 | return $constraint['REFERENCED_TABLE_NAME'];
97 | }
98 |
99 | /**
100 | * Retrieve the referenced column name
101 | *
102 | * @return string
103 | */
104 | public function getRefFkColumnName()
105 | {
106 | $constraint = $this->getConstraintData();
107 |
108 | return $constraint['REFERENCED_COLUMN_NAME'];
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/Block/InstallSchema/TableDeclaration/IndexDeclaration.php:
--------------------------------------------------------------------------------
1 | ' . $indexType . ']' : '[]';
39 | }
40 |
41 | /**
42 | * Retrieve the table indexes
43 | *
44 | * @return array
45 | */
46 | public function getIndexes()
47 | {
48 | if (!$this->hasData('indexes')) {
49 | $indexes = [];
50 |
51 | // Sort columns which are part of the same index
52 | foreach ($this->getColumns() as $column) {
53 | foreach ($column['CONSTRAINTS'] as $constraint) {
54 | $indexName = $constraint['INDEX_NAME'];
55 |
56 | // We only add the index other than the primary or foreign keys
57 | if ($this->isIndex($constraint)) {
58 | // Init data of the index
59 | if (!isset($indexes[$indexName])) {
60 | $indexes[$indexName] = [
61 | 'type' => $this->getIndexType($constraint),
62 | 'columns' => []
63 | ];
64 | }
65 |
66 | $indexes[$indexName]['columns'][] = $column['COLUMN_NAME'];
67 | }
68 | }
69 | }
70 |
71 | $this->setData('indexes', $indexes);
72 | }
73 |
74 | return $this->getData('indexes');
75 | }
76 |
77 | /**
78 | * Retrieve the index type from a constraint
79 | *
80 | * @param array $constraint
81 | * @return string
82 | */
83 | private function getIndexType(array $constraint)
84 | {
85 | $indexType = $constraint['CONSTRAINT_TYPE'];
86 |
87 | // Is unique, fulltext or simple index
88 | if (empty($indexType)) {
89 | if ($constraint['INDEX_TYPE'] === 'FULLTEXT') {
90 | $indexType = $constraint['INDEX_TYPE'];
91 | } else {
92 | $indexType = '';
93 | }
94 | }
95 |
96 | if (!empty($indexType)) {
97 | $indexType = 'AdapterInterface::INDEX_TYPE_' . $indexType;
98 | }
99 |
100 | return $indexType;
101 | }
102 |
103 | /**
104 | * Check if a given constraint is an index
105 | *
106 | * @param array $constraint
107 | * @return bool
108 | */
109 | private function isIndex(array $constraint)
110 | {
111 | return (
112 | !empty($constraint['INDEX_TYPE']) &&
113 | !empty($constraint['INDEX_NAME']) &&
114 | empty($constraint['REFERENCED_TABLE_NAME']) &&
115 | empty($constraint['REFERENCED_COLUMN_NAME']) &&
116 | $constraint['INDEX_NAME'] !== 'PRIMARY' &&
117 | !in_array(
118 | $constraint['CONSTRAINT_TYPE'],
119 | ['PRIMARY KEY', 'FOREIGN KEY'],
120 | true
121 | )
122 | );
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/Console/Command/InstallSchemaGeneratorCommand.php:
--------------------------------------------------------------------------------
1 | appState = $appState;
67 | $this->installSchemaBuilder = $installSchemaBuilder;
68 | parent::__construct($name);
69 | }
70 |
71 | /**
72 | * {@inheritdoc}
73 | */
74 | protected function configure()
75 | {
76 | $this->setName('isg:generate')
77 | ->setDescription('Generate the InstallSchema.php file for the database tables')
78 | ->setDefinition([
79 | new InputArgument(
80 | self::INPUT_DATABASE_TABLES,
81 | InputArgument::OPTIONAL | InputArgument::IS_ARRAY,
82 | 'Space-separated list of database tables or omit to apply to all database tables.'
83 | ),
84 | new InputOption(
85 | self::INPUT_NAMESPACE,
86 | '-p',
87 | InputOption::VALUE_REQUIRED,
88 | 'Set specific namespace to the InstallSchema class.'
89 | ),
90 | new InputOption(
91 | self::GENERATE_LOCATION,
92 | '-l',
93 | InputOption::VALUE_REQUIRED,
94 | 'Set the relative file location from the temp dir of your Magento, to generate the InstallSchema.php file.'
95 | ),
96 | ]);
97 |
98 | parent::configure();
99 | }
100 |
101 | /**
102 | * {@inheritdoc}
103 | */
104 | protected function execute(InputInterface $input, OutputInterface $output)
105 | {
106 | $returnCode = \Magento\Framework\Console\Cli::RETURN_SUCCESS;
107 | $this->appState->setAreaCode(\Magento\Framework\App\Area::AREA_GLOBAL);
108 |
109 | try {
110 | $filename = $this->installSchemaBuilder->generate(
111 | array_map('trim', $input->getArgument(self::INPUT_DATABASE_TABLES)),
112 | $input->getOption(self::INPUT_NAMESPACE),
113 | $input->getOption(self::GENERATE_LOCATION)
114 | );
115 |
116 | $output->writeln('The InstallSchema class file has been written in: ' . $filename . '');
117 | } catch (\Exception $e) {
118 | $output->writeln('' . $e->getMessage() . '');
119 | $returnCode = \Magento\Framework\Console\Cli::RETURN_FAILURE;
120 | }
121 |
122 | return $returnCode;
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/Controller/Adminhtml/Index/Index.php:
--------------------------------------------------------------------------------
1 | resultPageFactory = $resultPageFactory;
38 | parent::__construct($context);
39 | }
40 |
41 | /**
42 | * {@inheritdoc}
43 | */
44 | public function execute()
45 | {
46 | $resultPage = $this->resultPageFactory->create();
47 | $resultPage->setActiveMenu('Blackbird_InstallSchemaGenerator::retriever');
48 | $resultPage->addBreadcrumb(__('Install Schema Generator'), __('Install Schema Generator'));
49 | $resultPage->getConfig()->getTitle()->prepend(__('Install Schema Generator'));
50 |
51 | return $resultPage;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Controller/Adminhtml/Index/Retriever.php:
--------------------------------------------------------------------------------
1 | fileFactory = $fileFactory;
48 | $this->installSchemaBuilder = $installSchemaBuilder;
49 | parent::__construct($context);
50 | }
51 |
52 | /**
53 | * {@inheritdoc}
54 | */
55 | public function execute()
56 | {
57 | if (!$this->getRequest()->isPost()) {
58 | return $this->resultRedirectFactory->create()->setPath('*/*/');
59 | }
60 |
61 | $tables = $this->getRequest()->getParam('tables');
62 |
63 | if (!is_array($tables)) {
64 | $this->messageManager->addErrorMessage(__('Please select at least one table.'));
65 | } else {
66 | try {
67 | $filename = $this->installSchemaBuilder->generate($tables, $this->getCustomNamespace());
68 |
69 | $this->fileFactory->create(
70 | 'InstallSchema.php',
71 | ['type' => 'filename', 'value' => $filename],
72 | DirectoryList::TMP,
73 | 'application/octet-stream'
74 | );
75 | } catch (LocalizedException $e) {
76 | $this->messageManager->addErrorMessage($e->getMessage());
77 | } catch (\Exception $e) {
78 | $this->messageManager->addExceptionMessage($e, $e->getMessage());
79 | }
80 | }
81 |
82 | return $this->resultRedirectFactory->create()->setPath('*/*/');
83 | }
84 |
85 | /**
86 | * Retrieve the namespace param
87 | *
88 | * @return string
89 | */
90 | private function getCustomNamespace()
91 | {
92 | $vendor = trim($this->getRequest()->getParam('vendor'));
93 | $vendor = !empty($vendor) ? $vendor : 'Vendor';
94 | $module = trim($this->getRequest()->getParam('module'));
95 | $module = !empty($module) ? $module : 'Area';
96 |
97 | return $vendor . '\\' . $module;
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2018 Blackbird Agency
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Model/DB/SchemaRetriever.php:
--------------------------------------------------------------------------------
1 | resource = $resourceConnection;
42 | $dbConfig = $this->getConnection()->getConfig();
43 | $this->dbname = $dbConfig['dbname'];
44 | }
45 |
46 | /**
47 | * Retrieve all tables
48 | *
49 | * @todo remove/refactor
50 | * @return array
51 | */
52 | public function getTablesOptions()
53 | {
54 | $options = [];
55 |
56 | foreach ($this->getConnection()->getTables() as $table) {
57 | $options[] = [
58 | 'value' => $table,
59 | 'label' => $table,
60 | ];
61 | }
62 |
63 | return $options;
64 | }
65 |
66 | /**
67 | * Return the tables schema
68 | *
69 | * @param array $tables
70 | * @return array
71 | */
72 | public function getSchema(array $tables = [])
73 | {
74 | return $this->sanitizeSchema($this->querySchema($tables));
75 | }
76 |
77 | /**
78 | * Prepare and query the schema
79 | *
80 | * @param array $tables
81 | * @return array
82 | */
83 | private function querySchema(array $tables)
84 | {
85 | // Select all informations about columns, indexes and foreign keys
86 | $sql = "SELECT T.TABLE_NAME, T.TABLE_COMMENT,
87 | C.COLUMN_NAME, C.COLUMN_COMMENT, C.COLUMN_DEFAULT,
88 | C.COLUMN_TYPE, COLUMN_KEY, C.IS_NULLABLE,
89 | C.NUMERIC_PRECISION, C.NUMERIC_SCALE,
90 | C.DATETIME_PRECISION, C.EXTRA, S.INDEX_NAME,
91 | S.INDEX_TYPE, TC.CONSTRAINT_NAME, TC.CONSTRAINT_TYPE,
92 | KCU.REFERENCED_TABLE_NAME, KCU.REFERENCED_COLUMN_NAME,
93 | RC.DELETE_RULE
94 |
95 | FROM information_schema.TABLES T
96 | LEFT OUTER JOIN information_schema.COLUMNS AS C
97 | ON T.TABLE_CATALOG = C.TABLE_CATALOG
98 | AND T.TABLE_SCHEMA = C.TABLE_SCHEMA
99 | AND T.TABLE_NAME = C.TABLE_NAME
100 |
101 | LEFT OUTER JOIN information_schema.STATISTICS AS S
102 | ON T.TABLE_CATALOG = S.TABLE_CATALOG
103 | AND T.TABLE_SCHEMA = S.TABLE_SCHEMA
104 | AND T.TABLE_NAME = S.TABLE_NAME
105 | AND C.COLUMN_NAME = S.COLUMN_NAME
106 |
107 | LEFT OUTER JOIN information_schema.TABLE_CONSTRAINTS AS TC
108 | ON T.TABLE_SCHEMA = TC.TABLE_SCHEMA
109 | AND T.TABLE_NAME = TC.TABLE_NAME
110 | AND S.INDEX_NAME = TC.CONSTRAINT_NAME
111 |
112 | LEFT OUTER JOIN information_schema.KEY_COLUMN_USAGE AS KCU
113 | ON T.TABLE_CATALOG = KCU.TABLE_CATALOG
114 | AND T.TABLE_SCHEMA = KCU.TABLE_SCHEMA
115 | AND T.TABLE_NAME = KCU.TABLE_NAME
116 | AND C.COLUMN_NAME = KCU.COLUMN_NAME
117 |
118 | LEFT OUTER JOIN information_schema.REFERENTIAL_CONSTRAINTS AS RC
119 | ON KCU.CONSTRAINT_CATALOG = RC.CONSTRAINT_CATALOG
120 | AND KCU.CONSTRAINT_SCHEMA = RC.CONSTRAINT_SCHEMA
121 | AND KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME
122 | AND KCU.TABLE_NAME = RC.TABLE_NAME
123 | AND KCU.REFERENCED_TABLE_NAME = RC.REFERENCED_TABLE_NAME
124 |
125 | WHERE C.TABLE_SCHEMA = '" . $this->dbname . "'";
126 |
127 | // If no specific table is given, we return all database tables
128 | if (!empty($tables)) {
129 | $sql .= $this->getConnection()
130 | ->quoteInto(' AND C.TABLE_NAME IN (?)', $tables);
131 | }
132 |
133 | $sql .= " ORDER BY C.TABLE_NAME, C.ORDINAL_POSITION";
134 |
135 | // Prepare the query
136 | return $this->getConnection()->fetchAll($sql);
137 | }
138 |
139 | /**
140 | * Sort the columns by table in a sub array
141 | *
142 | * @param array $schema
143 | * @return array
144 | */
145 | private function sanitizeSchema(array $schema)
146 | {
147 | $finalSchema = [];
148 |
149 | foreach ($schema as $column) {
150 | $tabname = $column['TABLE_NAME'];
151 | $colname = $column['COLUMN_NAME'];
152 |
153 | if (!isset($finalSchema[$tabname])) {
154 | $finalSchema[$tabname] = [];
155 | }
156 | if (!isset($finalSchema[$tabname][$colname]['CONSTRAINTS'])) {
157 | $finalSchema[$tabname][$colname]['CONSTRAINTS'] = [];
158 | }
159 |
160 | $finalSchema[$tabname][$colname]['CONSTRAINTS'][] = [
161 | 'REFERENCED_TABLE_NAME' => $column['REFERENCED_TABLE_NAME'],
162 | 'REFERENCED_COLUMN_NAME' => $column['REFERENCED_COLUMN_NAME'],
163 | 'CONSTRAINT_NAME' => $column['CONSTRAINT_NAME'],
164 | 'INDEX_NAME' => $column['INDEX_NAME'],
165 | 'INDEX_TYPE' => $column['INDEX_TYPE'],
166 | 'CONSTRAINT_TYPE' => $column['CONSTRAINT_TYPE'],
167 | 'DELETE_RULE' => $column['DELETE_RULE']
168 | ];
169 |
170 | unset($column['REFERENCED_TABLE_NAME'], $column[11],
171 | $column['REFERENCED_COLUMN_NAME'], $column[12],
172 | $column['CONSTRAINT_NAME'], $column[13],
173 | $column['INDEX_NAME'], $column[14],
174 | $column['INDEX_TYPE'], $column[15],
175 | $column['CONSTRAINT_TYPE'], $column[16],
176 | $column['DELETE_RULE'], $column[17]
177 | );
178 |
179 | $column['CONSTRAINTS'] = $finalSchema[$tabname][$colname]['CONSTRAINTS'];
180 |
181 | $finalSchema[$tabname][$colname] = $column;
182 | }
183 |
184 | return $finalSchema;
185 | }
186 |
187 | /**
188 | * Retrieve the DB adapter connection
189 | *
190 | * @return AdapterInterface
191 | */
192 | private function getConnection()
193 | {
194 | return $this->resource->getConnection(ResourceConnection::DEFAULT_CONNECTION);
195 | }
196 | }
197 |
--------------------------------------------------------------------------------
/Model/SchemaSetupBuilder.php:
--------------------------------------------------------------------------------
1 | schemaRetriever = $schemaRetriever;
67 | $this->filesystem = $filesystem;
68 | $this->blockFactory = $blockFactory;
69 | }
70 |
71 | /**
72 | * {@inheritdoc}
73 | */
74 | public function generate(
75 | array $tables = [],
76 | $namespace = self::DEFAULT_NAMESPACE,
77 | $filename = self::DEFAULT_FILENAME
78 | ) {
79 | // Generate the renderer template block
80 | $block = $this->blockFactory->createBlock(InstallSchema::class)
81 | ->setNamespace($this->sanitizeNamespace($namespace))
82 | ->setTables($this->schemaRetriever->getSchema($tables));
83 |
84 | // Create the InstallSchema.php class file
85 | $writer = $this->filesystem->getDirectoryWrite(DirectoryList::TMP);
86 |
87 | $file = $writer->openFile($filename, 'w');
88 |
89 | try {
90 | $file->lock();
91 | $file->write($block->getHtml());
92 | } catch (\Exception $e) {
93 | throw new LocalizedException(__('An error has occurred during the generation of the %1 setup file.', $filename));
94 | } finally {
95 | $file->unlock();
96 | $file->close();
97 | }
98 |
99 | return $filename;
100 | }
101 |
102 | /**
103 | * Filter and sanitize the namespace input
104 | *
105 | * @param string $namespace
106 | * @return string
107 | */
108 | private function sanitizeNamespace($namespace)
109 | {
110 | return $this->isNamespace($namespace) ? $namespace : self::DEFAULT_NAMESPACE;
111 | }
112 |
113 | /**
114 | * If pattern is a part of namespace, then return it, else return false
115 | *
116 | * @param string $namespace
117 | * @return boolean|string
118 | */
119 | private function isNamespace($namespace)
120 | {
121 | return (!empty($namespace) && count(explode("\\", $namespace)) === 2);
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Install Schema Generator
2 |
3 | [](https://packagist.org/packages/blackbird/installschemagenerator)
4 | [](./LICENSE)
5 |
6 | **An extension for Magento 2 by Blackbird Agency**
7 |
8 | ## Synopsis
9 |
10 | This project is a developer tool destined to speed up the tables creation's scripts of a Magento 2 module.
11 | The purpose of this project is to make easier to create extra tables for your Magento 2 modules.
12 | For example, you love the Phpmyadmin UI and have designed your tables with it. But now you have to write the entire
13 | setup script for your Magento 2 module... If only you were allowed to generate this setup script from your tables...
14 | And here we are! That's why we offer you this module: it allows you to generate your InstallSchema.php setup file
15 | throught your database tables.
16 |
17 | ## How to use it
18 |
19 | Requirements:
20 |
21 | - You should have initialized a databasse and created your table(s)
22 |
23 | You can generate the setup file via two methods:
24 |
25 | - CLI command
26 | - UI Backend
27 |
28 | ### CLI Command
29 |
30 | Allowed CLI commands:
31 |
32 | php magento isg:generate [tables...]
33 |
34 | options:
35 |
36 | -n : custom namespace name for the file
37 | -l : location where to generate the file
38 |
39 | ### UI Backend
40 |
41 | - Connect to your Magento 2 admin panel, then go to System => Install Schema Generator
42 | - Insert your custom namespace
43 | - Select the tables to generate into a InstallSchema.php setup file
44 | - Download your file and enjoy it
45 |
46 | 
47 |
48 | ## Setup
49 |
50 | ### Get the package
51 |
52 | **Zip Package:**
53 |
54 | Unzip the package in app/code/Blackbird/InstallSchemaGenerator.
55 |
56 | **Composer Package:**
57 |
58 | ```
59 | composer require blackbird/installschemagenerator
60 | ```
61 |
62 | ### Install the module
63 |
64 | Then, run the following magento command:
65 |
66 | ```
67 | php bin/magento setup:upgrade
68 | ```
69 |
70 | **If you are in production mode, do not forget to recompile and redeploy the static resources.**
71 |
72 | ## Support
73 |
74 | Raise a [request](https://github.com/blackbird-agency/magento-2-install-schema-generator/issues).
75 |
76 | ## Authors
77 |
78 | - **Thomas Klein** - *Initial work* - [It's me!](https://github.com/thomas-kl1)
79 | - **Blackbird Team** - *Contributor* - [They're awesome!](https://github.com/blackbird-agency)
80 |
81 | ## Contact
82 |
83 | For further information, contact us:
84 |
85 | - by email: hello@bird.eu
86 | - or by form: [https://black.bird.eu/en/contacts/](https://black.bird.eu/contacts/)
87 |
88 | ## Licence
89 |
90 | This project is licensed under the Blackbird Policy License - see the [LICENSE](./LICENSE) link for details.
91 |
92 | ***That's all folks!***
93 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "blackbird/installschemagenerator",
3 | "description": "This module enable you to retrieve InstallSchema.php from tables of your choice",
4 | "type": "magento2-module",
5 | "keywords": [
6 | "magento",
7 | "install",
8 | "schema",
9 | "generator",
10 | "dev",
11 | "tool"
12 | ],
13 | "homepage": "https://github.com/blackbird-agency/magento-2-install-schema-generator",
14 | "version": "100.1.3",
15 | "require": {
16 | "magento/framework": ">=100.0.0",
17 | "magento/module-backend": ">=100.0.0",
18 | "symfony/console": "*"
19 | },
20 | "license": [
21 | "MIT"
22 | ],
23 | "authors": [
24 | {
25 | "name": "Thomas Klein",
26 | "email": "thomas@bird.eu",
27 | "homepage": "https://black.bird.eu/en/thomas-klein",
28 | "role": "lead"
29 | }
30 | ],
31 | "support": {
32 | "source": "https://github.com/blackbird-agency/magento-2-install-schema-generator",
33 | "issues": "https://github.com/blackbird-agency/magento-2-install-schema-generator/issues"
34 | },
35 | "autoload": {
36 | "files": [
37 | "registration.php"
38 | ],
39 | "psr-4": {
40 | "Blackbird\\InstallSchemaGenerator\\": ""
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/etc/acl.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/etc/adminhtml/menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 |
34 |
35 |
--------------------------------------------------------------------------------
/etc/adminhtml/routes.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/etc/di.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 |
21 |
22 |
23 |
24 | - Blackbird\InstallSchemaGenerator\Console\Command\InstallSchemaGeneratorCommand
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/etc/module.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/registration.php:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | infos_section
29 | installschemagenerator_retriever_edit_tab_infos
30 |
31 |
32 | tables_section
33 | installschemagenerator_retriever_edit_tab_tables
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/view/adminhtml/templates/install-schema.phtml:
--------------------------------------------------------------------------------
1 |
17 |
23 |
24 |
25 | /**
26 | * Custom license details...
27 | */
28 |
29 | namespace getNamespace() ?>;
30 |
31 | use Magento\Framework\DB\Adapter\AdapterInterface;
32 | use Magento\Framework\DB\Ddl\Table;
33 | use Magento\Framework\Setup\InstallSchemaInterface;
34 | use Magento\Framework\Setup\ModuleContextInterface;
35 | use Magento\Framework\Setup\SchemaSetupInterface;
36 |
37 | /**
38 | * @codeCoverageIgnore
39 | */
40 | class InstallSchema implements InstallSchemaInterface
41 | {
42 | /**
43 | * {@inheritdoc}
44 | * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
45 | */
46 | public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
47 | {
48 | $installer = $setup;
49 |
50 | $installer->startSetup();
51 |
52 | getTables() as $tableName => $columns): ?>
53 | getTableDeclarationHtml($tableName, $columns), PHP_EOL; ?>
54 |
55 |
56 | $installer->endSetup();
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/view/adminhtml/templates/install-schema/table-declaration.phtml:
--------------------------------------------------------------------------------
1 |
17 |
23 | /**
24 | * Create table 'getTableName(); ?>'
25 | */
26 | $table = $installer->getConnection()
27 | ->newTable($installer->getTable('getTableName(); ?>'))
28 | getColumns() as $column): ?>
29 | getColumnDeclarationHtml($column); ?>
30 |
31 | getIndexDeclarationHtml($this->getColumns()); ?>
32 | getColumns() as $column): ?>
33 |
34 | getForeignKeyDeclarationHtml($column['COLUMN_NAME'], $constraint); ?>
35 |
36 |
37 | ->setComment('getComment(); ?>');
38 | $installer->getConnection()->createTable($table);
39 |
--------------------------------------------------------------------------------
/view/adminhtml/templates/install-schema/table-declaration/column-declaration.phtml:
--------------------------------------------------------------------------------
1 |
17 |
23 | ->addColumn(
24 | 'getColumnName(); ?>',
25 | Table::TYPE_getColumnType(); ?>,
26 | 'getColumnSize(); ?>',
27 | [
28 | getOptions() as $key => $option): ?>
29 | '' => ,
30 |
31 | ],
32 | 'getColumnComment(); ?>'
33 | )
34 |
--------------------------------------------------------------------------------
/view/adminhtml/templates/install-schema/table-declaration/foreign-key-declaration.phtml:
--------------------------------------------------------------------------------
1 |
17 |
23 | isForeignKey()): ?>
24 | ->addForeignKey(
25 | $installer->getFkName(
26 | 'getFkTableName(); ?>',
27 | 'getFkColumnName(); ?>',
28 | 'getRefFkTableName(); ?>',
29 | 'getRefFkColumnName(); ?>'
30 | ),
31 | 'getFkColumnName(); ?>',
32 | $installer->getTable('getRefFkTableName(); ?>'),
33 | 'getRefFkColumnName(); ?>',
34 | Table::ACTION_getDeleteRule(); ?>
35 | )
36 |
37 |
--------------------------------------------------------------------------------
/view/adminhtml/templates/install-schema/table-declaration/index-declaration.phtml:
--------------------------------------------------------------------------------
1 |
17 |
23 | getIndexes() as $indexName => $index): ?>
24 | ->addIndex(
25 | $installer->getIdxName(
26 | 'getTableName(); ?>',
27 | [
28 |
29 | '',
30 |
31 | ],
32 |
33 | ),
34 | [
35 |
36 | '',
37 |
38 | ],
39 | getIndexTypeArrayFormat($index['type']), PHP_EOL; ?>
40 | )
41 |
42 |
--------------------------------------------------------------------------------
/view/global/templates/install-schema.phtml:
--------------------------------------------------------------------------------
1 |
17 |
23 |
24 |
25 | /**
26 | * Custom license details...
27 | */
28 |
29 | namespace getNamespace() ?>;
30 |
31 | use Magento\Framework\DB\Adapter\AdapterInterface;
32 | use Magento\Framework\DB\Ddl\Table;
33 | use Magento\Framework\Setup\InstallSchemaInterface;
34 | use Magento\Framework\Setup\ModuleContextInterface;
35 | use Magento\Framework\Setup\SchemaSetupInterface;
36 |
37 | /**
38 | * @codeCoverageIgnore
39 | */
40 | class InstallSchema implements InstallSchemaInterface
41 | {
42 | /**
43 | * {@inheritdoc}
44 | * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
45 | */
46 | public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
47 | {
48 | $installer = $setup;
49 |
50 | $installer->startSetup();
51 |
52 | getTables() as $tableName => $columns): ?>
53 | getTableDeclarationHtml($tableName, $columns), PHP_EOL; ?>
54 |
55 |
56 | $installer->endSetup();
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/view/global/templates/install-schema/table-declaration.phtml:
--------------------------------------------------------------------------------
1 |
17 |
23 | /**
24 | * Create table 'getTableName(); ?>'
25 | */
26 | $table = $installer->getConnection()
27 | ->newTable($installer->getTable('getTableName(); ?>'))
28 | getColumns() as $column): ?>
29 | getColumnDeclarationHtml($column); ?>
30 |
31 | getIndexDeclarationHtml($this->getColumns()); ?>
32 | getColumns() as $column): ?>
33 |
34 | getForeignKeyDeclarationHtml($column['COLUMN_NAME'], $constraint); ?>
35 |
36 |
37 | ->setComment('getComment(); ?>');
38 | $installer->getConnection()->createTable($table);
39 |
--------------------------------------------------------------------------------
/view/global/templates/install-schema/table-declaration/column-declaration.phtml:
--------------------------------------------------------------------------------
1 |
17 |
23 | ->addColumn(
24 | 'getColumnName(); ?>',
25 | Table::TYPE_getColumnType(); ?>,
26 | 'getColumnSize(); ?>',
27 | [
28 | getOptions() as $key => $option): ?>
29 | '' => ,
30 |
31 | ],
32 | 'getColumnComment(); ?>'
33 | )
34 |
--------------------------------------------------------------------------------
/view/global/templates/install-schema/table-declaration/foreign-key-declaration.phtml:
--------------------------------------------------------------------------------
1 |
17 |
23 | isForeignKey()): ?>
24 | ->addForeignKey(
25 | $installer->getFkName(
26 | 'getFkTableName(); ?>',
27 | 'getFkColumnName(); ?>',
28 | 'getRefFkTableName(); ?>',
29 | 'getRefFkColumnName(); ?>'
30 | ),
31 | 'getFkColumnName(); ?>',
32 | $installer->getTable('getRefFkTableName(); ?>'),
33 | 'getRefFkColumnName(); ?>',
34 | Table::ACTION_getDeleteRule(); ?>
35 | )
36 |
37 |
--------------------------------------------------------------------------------
/view/global/templates/install-schema/table-declaration/index-declaration.phtml:
--------------------------------------------------------------------------------
1 |
17 |
23 | getIndexes() as $indexName => $index): ?>
24 | ->addIndex(
25 | $installer->getIdxName(
26 | 'getTableName(); ?>',
27 | [
28 |
29 | '',
30 |
31 | ],
32 |
33 | ),
34 | [
35 |
36 | '',
37 |
38 | ],
39 | getIndexTypeArrayFormat($index['type']), PHP_EOL; ?>
40 | )
41 |
42 |
--------------------------------------------------------------------------------