Questions tagged [upgradeschema]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
95 views

Magento: Upgrade modules, Compile code, Deploy static content, Flush cache

I am running this gist after changing anything in module code. I need feedback for improving this gist & Magento 2 development. https://gist.github.com/enishant/211212beeadff49aba00c0622a0f33ab #!/...
Nishant's user avatar
  • 101
1 vote
2 answers
567 views

Magento2 : update query though upgradeData script

I want to update data to particular value in database. How to write script for the below query update tablename set name="Test" where id="4"
User0434's user avatar
  • 1,135
0 votes
2 answers
299 views

why setup upgrade command revert back already dropped foreign key in magento 2.4.2

I have written one custom module with a simple UpgradeSchema file to drop core foreign key (table product_alert_stock, foreign key name - PRODUCT_ALERT_STOCK_CUSTOMER_ID_CUSTOMER_ENTITY_ENTITY_ID ) ...
Param Kumar's user avatar
0 votes
1 answer
3k views

Magento 2 - change database column type

I need to change the type of the column "value" in the table catalog_product_entity_varchar from varchar(255) to varchar(512), but I find nothing in the documentation about how to do it, so ...
Black's user avatar
  • 3,150
0 votes
1 answer
466 views

Declare length of int column

How can I declare a size for an int? I have the following code: ... /** @var \Magento\Framework\Setup\SchemaSetupInterface $schemaSetup */ $table = $schemaSetup->getConnection() ...
domdambrogia's user avatar
0 votes
1 answer
63 views

I think I used UpgradeSchema wrongly , I have horrible error

I think I used UpgradeSchema wrongly , I have horrible error like 1 exception(s): Exception #0 (BadMethodCallException): Missing required argument $primaryFieldName of Magento\Framework\View\Element\...
Giga Todadze's user avatar
1 vote
0 answers
333 views

Magento 2 - Update foreign key default to null in UpgradeSchema

I created a foreign key in install schema for my custom table like this: $custom_table->addColumn( 'customer_id', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, null, ['nullable' =&...
jojo's user avatar
  • 149
0 votes
2 answers
410 views

Update Schema for Magento 2

How do I write update schema in Magento 2 for the following: $installer->run( "UPDATE {$this->getTable('catalog_eav_attribute')} SET `is_visible` = 0 WHERE `attribute_id` IN(SELECT `...
Adarsh Khatri's user avatar
3 votes
1 answer
1k views

How to rename an existing custom table in Magento 2?

I created a table with name "Redeem_blanace" using InstallSchema.php as: class InstallSchema implements InstallSchemaInterface { /** * {@inheritdoc} * @SuppressWarnings(PHPMD....
Ajwad Syed's user avatar
  • 1,591
0 votes
2 answers
1k views

Magento 2: Update database table add new columns like created_at and updated_at from module

UpgradeScema.php <?php namespace Lucent\MegaMenu\Setup; use Magento\Framework\Setup\UpgradeSchemaInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\...
Sarvesh Patel's user avatar
0 votes
1 answer
94 views

Error on creating UpgradeSchema.php

<?php namespace Essence\Slider\Setup; use Magento\Framework\Setup\UpgradeSchemaInterface; use Magento\Framework\Setup\SchemaSetupInterface; use Magento\Framework\Setup\...
Arshad Hussain's user avatar
1 vote
1 answer
88 views

Error Area Code is not set when Creating a virtual Product from Upgrade Schema

I'm using magento 2.2.5 , i want to make a virtual product programmatically using UpgradeSchema , but i alws got an error Upgrading data.. Area code is not set when i run bin/magento setup:upgrade ...
blue's user avatar
  • 118
1 vote
2 answers
348 views

How to create upgrade schema file second time

I want to create a new upgrade schema file in magento2. I already used the install schema and upgrade schema. I need to create a new upgrade schema.
venkata prasad's user avatar
4 votes
3 answers
8k views

How to add foreign key in db_schema.xml

I'm using magento 2.3 to create a custom module, i tried to create database tables for my custom module in etc/db_schema.xml like this: <table comment="province Table" engine="innodb&...
Idham Choudry's user avatar
0 votes
1 answer
567 views

Add foreign key on UpgradeSchema return "Foreign key constraint is incorrectly formed"?

I want to add a new attribute to catalog_product_website table named id_admin_user to make relation with admin_user table. PS: I want to do that to save the ID of the admin user who added a product. ...
sayou's user avatar
  • 363
0 votes
0 answers
37 views

URL field for Google Structured Data

What is the solution to add markup for product URL or even home page url? I tried many combinations calling product url, specifying url directly... Still Google structured data tool does not recognize ...
AlexT's user avatar
  • 1
0 votes
1 answer
64 views

GetPrice Function Adds Zeros at the end

I'm using this code for structured data. <meta itemprop="price" content="<?php echo $_product->getPrice(); ?>"> I get the price that I need but it adds ".0000" at the end. Please ...
AlexT's user avatar
  • 1
1 vote
1 answer
1k views

Error Add Foreign Key Using Install Schema Magento 2

<?php namespace Magneto\BookFreeLayout\Setup; use Magento\Framework\Setup\InstallSchemaInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\...
Harsh Jayswal's user avatar
3 votes
2 answers
2k views

Create new table to existing module in Magento2

I have created a new module and installed it, but did not include Setup/InstallSchema.php to create the table first time. Once the module is created can we create new table using InstallSchema.php? ...
Jafar Pinjar's user avatar
  • 1,929
0 votes
0 answers
145 views

Facing error when upgrading schema in magento2

Installing schema... Upgrading schema... SQLSTATE[42S02]: Base table or view not found: 1146 Table 'st_m2_225_21082018.sentence_sentence' doesn't exist, query was: DESCRIBE SENTENCE_SENTENCE <?php ...
Rutvee Sojitra's user avatar
0 votes
1 answer
1k views

UpgradeSchema not working in Magento 2.2.5?

I have make setup:upgrade with changing module version here is my code: <?php namespace Tatva\ProductImport\Setup; use Magento\Framework\Setup\UpgradeSchemaInterface; use Magento\...
Rutvee Sojitra's user avatar
2 votes
2 answers
3k views

Magento 2 Add new Customer Attribute via UpgradeSchema

I have a module that has customer attributes added via the InstallSchema Script, however I have an UpgradeSchema script to also add more customer attributes; Error below when running update in ...
BENN1TH's user avatar
  • 814
5 votes
2 answers
2k views

How to add new table in existing module using UpgradeSchema in Magento 2

class UpgradeSchema implements UpgradeSchemaInterface { public function upgrade(SchemaSetupInterface $setup,ModuleContextInterface $context){ $setup->startSetup(); if (...
sudo55's user avatar
  • 994
1 vote
0 answers
48 views

Magento2 - how to automatically create UpgradeData, UpgradeSchema based on existing table(s)

Who knows is there any tools, modules or whatever to convert existing table dump and structure into UpgradeData, UpgradeSchema? Why? For example you created complicated settings stored in DB and you ...
melaxon's user avatar
  • 340
5 votes
3 answers
5k views

Area code not set: Area code must be set before starting a session when UpgradeData

I'm using magento verison 2.2.5 and i try to use Setup/UpgradeData.php to run a model function to insert data into database from an external API. but when i run php bin/magento setup:upgrade i always ...
Tiny Dancer's user avatar
0 votes
1 answer
54 views

Warning when upgrade scripts?

if (version_compare($context->getVersion(), '1.1.10', '<=')) { $installer = $setup; $installer->startSetup(); // Get tutorial_simplenews table ...
nick's user avatar
  • 41
1 vote
3 answers
5k views

Magento 2 : UpgradeData.php not working

I need to add a custom attribute (contact_number) for customer in Magento2 via an existing module, so I am using UpgradeData.php. Can anyone please tell what I have missed out. use Magento\Framework\...
Narendra Vyas's user avatar
2 votes
0 answers
509 views

Magento integration test conflict with new customer eav attribute

I tried to run my integration test using bin/magento dev:tests:run integration but i always got an error like this: Module 'Company_CutomerExtraAttribute': Upgrading data... [Magento\Framework\...
Idham Choudry's user avatar
0 votes
1 answer
632 views

error : add foreign keys in UpgradeSchema

I am trying to give foreign keys in Upgrade Schema but it is still not working class UpgradeSchema implements UpgradeSchemaInterface { public function upgrade(SchemaSetupInterface $setup, ...
Dipak Solanki's user avatar
0 votes
1 answer
432 views

Magento 2: UpgradeData duplicates static blocks when I try to update them

My code looks like this: /** * @var \Magento\Cms\Model\BlockFactory */ private $_blockFactory; ... $this->_blockFactory ->setStoreId(0) ->load('some-identifier', '...
Pini's user avatar
  • 917
1 vote
1 answer
149 views

Magento 2.1.7 custom module UpgradeSchema not adding column

I'm not able to add new column to existing table UpgradeSchema.php: namespace Company\Module\Setup; use Magento\Framework\Setup\UpgradeSchemaInterface; use Magento\Framework\Setup\...
Juliano Vargas's user avatar
1 vote
1 answer
545 views

Magento 2. Update customer attribute outside Setup [Install|Upgrade]Data

I'm trying to ad a customer attribute outside a Setup Script. To be more specific inside a console command using CustomerSetupFactory::updateAttribute method. I get an error caused by DI. Argument ...
vitoriodachef's user avatar
0 votes
1 answer
647 views

Modification of Magento 2 database core table

I am getting this error in UpgradeSchema. I have added one column in these core tables, functionalities are working good. According to coding standard it shows warning message. ----------------------...
chris's user avatar
  • 341
1 vote
0 answers
301 views

Custom attribute not updated in Magento 2

I am new to Magento 2. We have created a custom module in Magento 2. We have successfully created a custom attribute in that module and created installdata.php file in the custom module. My problem ...
Amol Kumbhar's user avatar
0 votes
1 answer
71 views

Base Table or View not found after adding Category EAV

Ive tried to add my custom category eav attribute but after setup:upgrade and setup:di:compile I get the following error: 2 exception(s): Exception #0 (Zend_Db_Statement_Exception): SQLSTATE[42S02]: ...
Code Spirit's user avatar
1 vote
2 answers
2k views

UpgradeSchema/InstallData files not working

I've the following setup: Company/Custom/etc/module.xml: <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:...
learningmagento2's user avatar
0 votes
2 answers
238 views

Problem with add an attribute to Customer in magento 2

I created a module in this way: I created a vendor folder "Test1" Then I created a module folder "AddCustomerAttr" then a folder inside the module "etc" and inside "etc" I put module.xml: <?xml ...
M Taheri's user avatar
9 votes
5 answers
17k views

Magento 2 How to add foreign key in update schema

I try to add foreign key constrains for Magento 2 existing tables. I have UpdateSchema script but it's not working. <?php namespace Retailers\Customer\Setup; use Magento\Framework\Setup\...
Rajesh Nagappan's user avatar
0 votes
1 answer
317 views

Editing in UpgradeSchema.php method does not apply after running setup:upgrade

I have written a small module and I've made Setup classes include InstallData, InstallSchema, UpgradeData, and UpgradeSchema and put them in Setup folder, For the first time I did run setup:upgrade ...
M Taheri's user avatar
1 vote
0 answers
338 views

Magento 2 : UpgradeSchema write mysql trigger

I am trying to add mysql trigger using the upgradeschema in magento 2 but I am getting the "Cannot execute multiple queries". Below is my trigger DELIMITER $$ CREATE TRIGGER ...
manish_khot's user avatar
0 votes
1 answer
39 views

SchemaUpgrade issue in Magento 2

Today I'm learning Upgrading schema and Upgrading data, for this I am created simple table with version0.0.1 and it's working fine. Later I written code for UpgradeSchema. But it is not working for ...
Manoj Kumar's user avatar
  • 1,348
1 vote
1 answer
2k views

Magento-2 How to add website_id column to my custom existing table by Upgrade Schema

I want to add website_id column to my custom table with index and foreign key by UpgradeSchema. It is easy to add by InstallSchema but I want to add website_id column by UpgradeSchema in my existing ...
Suresh Chikani's user avatar
0 votes
1 answer
37 views

SchemaUpdate is not executed after running setup script

I am trying to run some Setup\UpgradeSchema.php lines. I run: php bin/magento setup:upgrade And my module code is not executed. My Setup\UpgradeSchema.php looks more or less like this: if (...
awavi's user avatar
  • 989
2 votes
1 answer
4k views

magento 2 UpgradeSchema not working

I have already created a table with name tutorial_simplenews.I want to add new column to that table.my code is below. <?php /** * Copyright © 2013-2017 Magento, Inc. All rights reserved. * See ...
Kamlesh Jha's user avatar
  • 1,058
3 votes
2 answers
3k views

Make column unique in install schema script

I want my column to be unique. It is not an EAV attribute. I have seen some tutorials, where indexes are unique, but I am not sure it is not the same, as making column unique (or am I wrong?). Is ...
Bartosz Kubicki's user avatar
2 votes
1 answer
116 views

I'm creating new Attribute for Category and facing an issue in Magento 2.X

My Upgrade Script : <?php namespace MyCompany\MyModule\Setup; use Magento\Framework\Module\Setup\Migration; use Magento\Framework\Setup\UpgradeSchemaInterface; use Magento\Framework\Setup\...
Pankaj's user avatar
  • 21
13 votes
4 answers
38k views

Add column Upgrade Schema Magento 2

I want to insert new field for database table in my custom extension using upgrade schema by following this post,but i got an error saying : [Zend_Db_Statement_Exception] ...
Shell Suite's user avatar
  • 1,702
1 vote
1 answer
401 views

Magento 2 : How to Create Simple Product by UpgradeSchema?

How do I create a simple product programmatically using UpgradeSchema?
St3phan's user avatar
  • 2,887