Magento 2 foreign key
Hey i need to setup the install shema of my module with 2 table and a third table thatmake the link between the two.
First table have id_provider
the second id_company
i want my third have the wo id.
It is foreign key ?
I do the following :
<?php
namespace EureciaCatalogSetup;
use MagentoFrameworkSetupInstallSchemaInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupSchemaSetupInterface;
use MagentoFrameworkDBDdlTable;
use MagentoFrameworkDBAdapterAdapterInterface;
class InstallSchema implements InstallSchemaInterface
{
/**
* {@inheritdoc}
*/
public function install(
SchemaSetupInterface $setup,
ModuleContextInterface $context
) {
$installer = $setup;
$installer->startSetup();
// Get eurecia_catalog table
$tableName = $installer->getTable('eurecia_providers');
// Check if the table already exists
if ($installer->getConnection()->isTableExists($tableName) != true) {
// Create eurecia_catalog table
$table = $installer->getConnection()
->newTable($tableName)
->addColumn(
'id_provider',
Table::TYPE_INTEGER,
null,
[
'identity' => true,
'unsigned' => true,
'nullable' => false,
'primary' => true
],
'ID Provider'
)
->addColumn(
'name',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Name'
)
->addColumn(
'subdomain',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Subdomain'
)
->addColumn(
'summary',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Summary'
)
->addColumn(
'address',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Address'
)
->addColumn(
'maxdist',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Maxdist'
)
->addColumn(
'status',
Table::TYPE_SMALLINT,
null,
['nullable' => false, 'default' => '0'],
'Status'
)
->setComment('Catalog Table')
->setOption('type', 'InnoDB')
->setOption('charset', 'utf8');
$installer->getConnection()->createTable($table);
}
// Get eurecia_company table
$tableName = $installer->getTable('eurecia_company');
// Check if the table already exists
if ($installer->getConnection()->isTableExists($tableName) != true) {
// Create eurecia_company table
$table = $installer->getConnection()
->newTable($tableName)
->addColumn(
'id_company',
Table::TYPE_INTEGER,
null,
[
'identity' => true,
'unsigned' => true,
'nullable' => false,
'primary' => true
],
'ID Company'
)
->addColumn(
'name',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Name'
)
->addColumn(
'subdomain',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Subdomain'
)
->addColumn(
'address',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Address'
)
->addColumn(
'status',
Table::TYPE_SMALLINT,
null,
['nullable' => false, 'default' => '0'],
'Status'
)
->setComment('Catalog Table')
->setOption('type', 'InnoDB')
->setOption('charset', 'utf8');
$installer->getConnection()->createTable($table);
}
if (!$installer->tableExists('eurecia_catalog_assoc')) {
$table = $installer->getConnection()
->newTable($installer->getTable('eurecia_catalog_assoc'));
$table->addColumn(
'id_company',
Table::TYPE_INTEGER,
null,
[
'unsigned' => true,
'nullable' => false,
'primary' => true,
],
'company ID'
)
->addColumn(
'id_provider',
Table::TYPE_INTEGER,
null,
[
'unsigned' => true,
'nullable' => false,
'primary' => true,
],
'provider ID'
)
->addColumn(
'position',
Table::TYPE_INTEGER,
null,
[
'nullable' => false,
'default' => '0'
],
'Position'
)
->addIndex(
$installer->getIdxName('eurecia_catalog_assoc', ['id_company']),
['id_company']
)
->addIndex(
$installer->getIdxName('eurecia_catalog_assoc', ['id_provider']),
['id_provider']
)
->addForeignKey(
$installer->getFkName(
'eurecia_catalog_assoc',
'id_company',
'eurecia_company',
'id_company'
),
'id_company',
$installer->getTable('eurecia_company'),
'id_company',
Table::ACTION_CASCADE,
Table::ACTION_CASCADE
)
->addForeignKey(
$installer->getFkName(
'eurecia_catalog_assoc',
'id_provider',
'eurecia_providers',
'id_provider'
),
'id_provider',
$installer->getTable('eurecia_providers'),
'id_provider',
Table::ACTION_CASCADE,
Table::ACTION_CASCADE
)
->addIndex(
$installer->getIdxName(
'eurecia_catalog_assoc',
[
'id_company',
'id_provider'
],
AdapterInterface::INDEX_TYPE_UNIQUE
),
[
'id_company',
'id_provider'
],
[
'type' => AdapterInterface::INDEX_TYPE_UNIQUE
]
)
->setComment('Company to provider Link Table');
$installer->getConnection()->createTable($table);
}
$setup->endSetup();
}
}
I get an error 1215 in my cmd when i do phpbin/magento setup:upgrade
I look on forum but i don't know where i am wrong ...
magento2 magento-2.1 database install-script setup-upgrade
bumped to the homepage by Community♦ 6 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
Hey i need to setup the install shema of my module with 2 table and a third table thatmake the link between the two.
First table have id_provider
the second id_company
i want my third have the wo id.
It is foreign key ?
I do the following :
<?php
namespace EureciaCatalogSetup;
use MagentoFrameworkSetupInstallSchemaInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupSchemaSetupInterface;
use MagentoFrameworkDBDdlTable;
use MagentoFrameworkDBAdapterAdapterInterface;
class InstallSchema implements InstallSchemaInterface
{
/**
* {@inheritdoc}
*/
public function install(
SchemaSetupInterface $setup,
ModuleContextInterface $context
) {
$installer = $setup;
$installer->startSetup();
// Get eurecia_catalog table
$tableName = $installer->getTable('eurecia_providers');
// Check if the table already exists
if ($installer->getConnection()->isTableExists($tableName) != true) {
// Create eurecia_catalog table
$table = $installer->getConnection()
->newTable($tableName)
->addColumn(
'id_provider',
Table::TYPE_INTEGER,
null,
[
'identity' => true,
'unsigned' => true,
'nullable' => false,
'primary' => true
],
'ID Provider'
)
->addColumn(
'name',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Name'
)
->addColumn(
'subdomain',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Subdomain'
)
->addColumn(
'summary',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Summary'
)
->addColumn(
'address',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Address'
)
->addColumn(
'maxdist',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Maxdist'
)
->addColumn(
'status',
Table::TYPE_SMALLINT,
null,
['nullable' => false, 'default' => '0'],
'Status'
)
->setComment('Catalog Table')
->setOption('type', 'InnoDB')
->setOption('charset', 'utf8');
$installer->getConnection()->createTable($table);
}
// Get eurecia_company table
$tableName = $installer->getTable('eurecia_company');
// Check if the table already exists
if ($installer->getConnection()->isTableExists($tableName) != true) {
// Create eurecia_company table
$table = $installer->getConnection()
->newTable($tableName)
->addColumn(
'id_company',
Table::TYPE_INTEGER,
null,
[
'identity' => true,
'unsigned' => true,
'nullable' => false,
'primary' => true
],
'ID Company'
)
->addColumn(
'name',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Name'
)
->addColumn(
'subdomain',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Subdomain'
)
->addColumn(
'address',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Address'
)
->addColumn(
'status',
Table::TYPE_SMALLINT,
null,
['nullable' => false, 'default' => '0'],
'Status'
)
->setComment('Catalog Table')
->setOption('type', 'InnoDB')
->setOption('charset', 'utf8');
$installer->getConnection()->createTable($table);
}
if (!$installer->tableExists('eurecia_catalog_assoc')) {
$table = $installer->getConnection()
->newTable($installer->getTable('eurecia_catalog_assoc'));
$table->addColumn(
'id_company',
Table::TYPE_INTEGER,
null,
[
'unsigned' => true,
'nullable' => false,
'primary' => true,
],
'company ID'
)
->addColumn(
'id_provider',
Table::TYPE_INTEGER,
null,
[
'unsigned' => true,
'nullable' => false,
'primary' => true,
],
'provider ID'
)
->addColumn(
'position',
Table::TYPE_INTEGER,
null,
[
'nullable' => false,
'default' => '0'
],
'Position'
)
->addIndex(
$installer->getIdxName('eurecia_catalog_assoc', ['id_company']),
['id_company']
)
->addIndex(
$installer->getIdxName('eurecia_catalog_assoc', ['id_provider']),
['id_provider']
)
->addForeignKey(
$installer->getFkName(
'eurecia_catalog_assoc',
'id_company',
'eurecia_company',
'id_company'
),
'id_company',
$installer->getTable('eurecia_company'),
'id_company',
Table::ACTION_CASCADE,
Table::ACTION_CASCADE
)
->addForeignKey(
$installer->getFkName(
'eurecia_catalog_assoc',
'id_provider',
'eurecia_providers',
'id_provider'
),
'id_provider',
$installer->getTable('eurecia_providers'),
'id_provider',
Table::ACTION_CASCADE,
Table::ACTION_CASCADE
)
->addIndex(
$installer->getIdxName(
'eurecia_catalog_assoc',
[
'id_company',
'id_provider'
],
AdapterInterface::INDEX_TYPE_UNIQUE
),
[
'id_company',
'id_provider'
],
[
'type' => AdapterInterface::INDEX_TYPE_UNIQUE
]
)
->setComment('Company to provider Link Table');
$installer->getConnection()->createTable($table);
}
$setup->endSetup();
}
}
I get an error 1215 in my cmd when i do phpbin/magento setup:upgrade
I look on forum but i don't know where i am wrong ...
magento2 magento-2.1 database install-script setup-upgrade
bumped to the homepage by Community♦ 6 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
Hey i need to setup the install shema of my module with 2 table and a third table thatmake the link between the two.
First table have id_provider
the second id_company
i want my third have the wo id.
It is foreign key ?
I do the following :
<?php
namespace EureciaCatalogSetup;
use MagentoFrameworkSetupInstallSchemaInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupSchemaSetupInterface;
use MagentoFrameworkDBDdlTable;
use MagentoFrameworkDBAdapterAdapterInterface;
class InstallSchema implements InstallSchemaInterface
{
/**
* {@inheritdoc}
*/
public function install(
SchemaSetupInterface $setup,
ModuleContextInterface $context
) {
$installer = $setup;
$installer->startSetup();
// Get eurecia_catalog table
$tableName = $installer->getTable('eurecia_providers');
// Check if the table already exists
if ($installer->getConnection()->isTableExists($tableName) != true) {
// Create eurecia_catalog table
$table = $installer->getConnection()
->newTable($tableName)
->addColumn(
'id_provider',
Table::TYPE_INTEGER,
null,
[
'identity' => true,
'unsigned' => true,
'nullable' => false,
'primary' => true
],
'ID Provider'
)
->addColumn(
'name',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Name'
)
->addColumn(
'subdomain',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Subdomain'
)
->addColumn(
'summary',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Summary'
)
->addColumn(
'address',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Address'
)
->addColumn(
'maxdist',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Maxdist'
)
->addColumn(
'status',
Table::TYPE_SMALLINT,
null,
['nullable' => false, 'default' => '0'],
'Status'
)
->setComment('Catalog Table')
->setOption('type', 'InnoDB')
->setOption('charset', 'utf8');
$installer->getConnection()->createTable($table);
}
// Get eurecia_company table
$tableName = $installer->getTable('eurecia_company');
// Check if the table already exists
if ($installer->getConnection()->isTableExists($tableName) != true) {
// Create eurecia_company table
$table = $installer->getConnection()
->newTable($tableName)
->addColumn(
'id_company',
Table::TYPE_INTEGER,
null,
[
'identity' => true,
'unsigned' => true,
'nullable' => false,
'primary' => true
],
'ID Company'
)
->addColumn(
'name',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Name'
)
->addColumn(
'subdomain',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Subdomain'
)
->addColumn(
'address',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Address'
)
->addColumn(
'status',
Table::TYPE_SMALLINT,
null,
['nullable' => false, 'default' => '0'],
'Status'
)
->setComment('Catalog Table')
->setOption('type', 'InnoDB')
->setOption('charset', 'utf8');
$installer->getConnection()->createTable($table);
}
if (!$installer->tableExists('eurecia_catalog_assoc')) {
$table = $installer->getConnection()
->newTable($installer->getTable('eurecia_catalog_assoc'));
$table->addColumn(
'id_company',
Table::TYPE_INTEGER,
null,
[
'unsigned' => true,
'nullable' => false,
'primary' => true,
],
'company ID'
)
->addColumn(
'id_provider',
Table::TYPE_INTEGER,
null,
[
'unsigned' => true,
'nullable' => false,
'primary' => true,
],
'provider ID'
)
->addColumn(
'position',
Table::TYPE_INTEGER,
null,
[
'nullable' => false,
'default' => '0'
],
'Position'
)
->addIndex(
$installer->getIdxName('eurecia_catalog_assoc', ['id_company']),
['id_company']
)
->addIndex(
$installer->getIdxName('eurecia_catalog_assoc', ['id_provider']),
['id_provider']
)
->addForeignKey(
$installer->getFkName(
'eurecia_catalog_assoc',
'id_company',
'eurecia_company',
'id_company'
),
'id_company',
$installer->getTable('eurecia_company'),
'id_company',
Table::ACTION_CASCADE,
Table::ACTION_CASCADE
)
->addForeignKey(
$installer->getFkName(
'eurecia_catalog_assoc',
'id_provider',
'eurecia_providers',
'id_provider'
),
'id_provider',
$installer->getTable('eurecia_providers'),
'id_provider',
Table::ACTION_CASCADE,
Table::ACTION_CASCADE
)
->addIndex(
$installer->getIdxName(
'eurecia_catalog_assoc',
[
'id_company',
'id_provider'
],
AdapterInterface::INDEX_TYPE_UNIQUE
),
[
'id_company',
'id_provider'
],
[
'type' => AdapterInterface::INDEX_TYPE_UNIQUE
]
)
->setComment('Company to provider Link Table');
$installer->getConnection()->createTable($table);
}
$setup->endSetup();
}
}
I get an error 1215 in my cmd when i do phpbin/magento setup:upgrade
I look on forum but i don't know where i am wrong ...
magento2 magento-2.1 database install-script setup-upgrade
Hey i need to setup the install shema of my module with 2 table and a third table thatmake the link between the two.
First table have id_provider
the second id_company
i want my third have the wo id.
It is foreign key ?
I do the following :
<?php
namespace EureciaCatalogSetup;
use MagentoFrameworkSetupInstallSchemaInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupSchemaSetupInterface;
use MagentoFrameworkDBDdlTable;
use MagentoFrameworkDBAdapterAdapterInterface;
class InstallSchema implements InstallSchemaInterface
{
/**
* {@inheritdoc}
*/
public function install(
SchemaSetupInterface $setup,
ModuleContextInterface $context
) {
$installer = $setup;
$installer->startSetup();
// Get eurecia_catalog table
$tableName = $installer->getTable('eurecia_providers');
// Check if the table already exists
if ($installer->getConnection()->isTableExists($tableName) != true) {
// Create eurecia_catalog table
$table = $installer->getConnection()
->newTable($tableName)
->addColumn(
'id_provider',
Table::TYPE_INTEGER,
null,
[
'identity' => true,
'unsigned' => true,
'nullable' => false,
'primary' => true
],
'ID Provider'
)
->addColumn(
'name',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Name'
)
->addColumn(
'subdomain',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Subdomain'
)
->addColumn(
'summary',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Summary'
)
->addColumn(
'address',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Address'
)
->addColumn(
'maxdist',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Maxdist'
)
->addColumn(
'status',
Table::TYPE_SMALLINT,
null,
['nullable' => false, 'default' => '0'],
'Status'
)
->setComment('Catalog Table')
->setOption('type', 'InnoDB')
->setOption('charset', 'utf8');
$installer->getConnection()->createTable($table);
}
// Get eurecia_company table
$tableName = $installer->getTable('eurecia_company');
// Check if the table already exists
if ($installer->getConnection()->isTableExists($tableName) != true) {
// Create eurecia_company table
$table = $installer->getConnection()
->newTable($tableName)
->addColumn(
'id_company',
Table::TYPE_INTEGER,
null,
[
'identity' => true,
'unsigned' => true,
'nullable' => false,
'primary' => true
],
'ID Company'
)
->addColumn(
'name',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Name'
)
->addColumn(
'subdomain',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Subdomain'
)
->addColumn(
'address',
Table::TYPE_TEXT,
null,
['nullable' => false, 'default' => ''],
'Address'
)
->addColumn(
'status',
Table::TYPE_SMALLINT,
null,
['nullable' => false, 'default' => '0'],
'Status'
)
->setComment('Catalog Table')
->setOption('type', 'InnoDB')
->setOption('charset', 'utf8');
$installer->getConnection()->createTable($table);
}
if (!$installer->tableExists('eurecia_catalog_assoc')) {
$table = $installer->getConnection()
->newTable($installer->getTable('eurecia_catalog_assoc'));
$table->addColumn(
'id_company',
Table::TYPE_INTEGER,
null,
[
'unsigned' => true,
'nullable' => false,
'primary' => true,
],
'company ID'
)
->addColumn(
'id_provider',
Table::TYPE_INTEGER,
null,
[
'unsigned' => true,
'nullable' => false,
'primary' => true,
],
'provider ID'
)
->addColumn(
'position',
Table::TYPE_INTEGER,
null,
[
'nullable' => false,
'default' => '0'
],
'Position'
)
->addIndex(
$installer->getIdxName('eurecia_catalog_assoc', ['id_company']),
['id_company']
)
->addIndex(
$installer->getIdxName('eurecia_catalog_assoc', ['id_provider']),
['id_provider']
)
->addForeignKey(
$installer->getFkName(
'eurecia_catalog_assoc',
'id_company',
'eurecia_company',
'id_company'
),
'id_company',
$installer->getTable('eurecia_company'),
'id_company',
Table::ACTION_CASCADE,
Table::ACTION_CASCADE
)
->addForeignKey(
$installer->getFkName(
'eurecia_catalog_assoc',
'id_provider',
'eurecia_providers',
'id_provider'
),
'id_provider',
$installer->getTable('eurecia_providers'),
'id_provider',
Table::ACTION_CASCADE,
Table::ACTION_CASCADE
)
->addIndex(
$installer->getIdxName(
'eurecia_catalog_assoc',
[
'id_company',
'id_provider'
],
AdapterInterface::INDEX_TYPE_UNIQUE
),
[
'id_company',
'id_provider'
],
[
'type' => AdapterInterface::INDEX_TYPE_UNIQUE
]
)
->setComment('Company to provider Link Table');
$installer->getConnection()->createTable($table);
}
$setup->endSetup();
}
}
I get an error 1215 in my cmd when i do phpbin/magento setup:upgrade
I look on forum but i don't know where i am wrong ...
magento2 magento-2.1 database install-script setup-upgrade
magento2 magento-2.1 database install-script setup-upgrade
asked Jun 7 '17 at 15:27
NundraNundra
98110
98110
bumped to the homepage by Community♦ 6 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 6 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I just had a similar problem and found out that when you specify the key column without a length, this error appears.
So to fix it, use a length for the Integer here:
->addColumn(
'id_company',
Table::TYPE_INTEGER,
10,
[
'identity' => true,
'unsigned' => true,
'nullable' => false,
'primary' => true
],
'ID Company'
)
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f177917%2fmagento-2-foreign-key%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I just had a similar problem and found out that when you specify the key column without a length, this error appears.
So to fix it, use a length for the Integer here:
->addColumn(
'id_company',
Table::TYPE_INTEGER,
10,
[
'identity' => true,
'unsigned' => true,
'nullable' => false,
'primary' => true
],
'ID Company'
)
add a comment |
I just had a similar problem and found out that when you specify the key column without a length, this error appears.
So to fix it, use a length for the Integer here:
->addColumn(
'id_company',
Table::TYPE_INTEGER,
10,
[
'identity' => true,
'unsigned' => true,
'nullable' => false,
'primary' => true
],
'ID Company'
)
add a comment |
I just had a similar problem and found out that when you specify the key column without a length, this error appears.
So to fix it, use a length for the Integer here:
->addColumn(
'id_company',
Table::TYPE_INTEGER,
10,
[
'identity' => true,
'unsigned' => true,
'nullable' => false,
'primary' => true
],
'ID Company'
)
I just had a similar problem and found out that when you specify the key column without a length, this error appears.
So to fix it, use a length for the Integer here:
->addColumn(
'id_company',
Table::TYPE_INTEGER,
10,
[
'identity' => true,
'unsigned' => true,
'nullable' => false,
'primary' => true
],
'ID Company'
)
answered Jan 6 '18 at 21:42
EssGeeEssGee
9118
9118
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f177917%2fmagento-2-foreign-key%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown