Magento 2 – Module Error After Enabling and Setup:Upgrade

magento2module

This question has been asked a
few
times but no excepted answers, and none of the suggestions worked for me. Here is the error:

1 exception(s):
Exception #0 (Magento\Framework\Exception\LocalizedException): Please upgrade your database: Run "bin/magento setup:upgrade" from the Magento root directory. 
The following modules are outdated:
Dope_CustomModule data: current version - none, required version - 1.0.0

Seems simple and the error says to run setup:upgrade. Of course I already did that when I installed my module.

I originally had a typo in my registration.php where I put Dopes_CustomModule instead of Dope_CustomModule. Magento 2 seems to hate when I rename themes and modules and so I suspect the typo may have caused this problem to persist. The setup:upgrade process still went through without error (the error shows up on page load to be clear).

I've cleared pub/static/*, var/di/* var/generation/*, var/cache/* and I've triple checked for typos in the code. I enabled/re-enabled several times, I recompiled. Nothing.

I've tried a few times and I notice that the data_version column in my setup_module is always NULL, resulting in the above error. If I change the NULL value of the data_version column in the DB from anything but NULL, including an empty string, my page loads. I did check into this any further, it should be obvious that this "fix" is not really a fix and I'd like something that doesn't require digging into the db, but maybe that helps answer the question.

So why is data_version NULL and why am I getting the above error?

# File: module.xml:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Dope_CustomModule" setup_version="1.0.0"/>
</config>

developer mode Running Magento 2.1.0 CE locally

Best Answer

Go to setup_module Table

Find your module Dope_CustomModule.

Make sure schema_version & data_version should be same as per your current module.

Then run

php bin/magento setup:upgrade

Everything works fine

Related Topic