Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB column missing #2

Closed
rostockahoi opened this issue Dec 7, 2021 · 4 comments
Closed

DB column missing #2

rostockahoi opened this issue Dec 7, 2021 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@rostockahoi
Copy link

Hi there,
I required and installed the plugin in a project on machine A. Everything works as expected. After committing and pushing the composer JSON and lock file, pulling it on machine B, running composer insall, then ./craft migrate/all it seems the database migration was not executed. It says No new migrations found. Your system is up to date..

When hitting the "Create entry" button for an entry type that uses one of the plugin methods in its fields an exception is thrown:

[yii\db\Exception] PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'metadata' in 'field list' in /var/www/site/vendor/yiisoft/yii2/db/Command.php:1302

My workaround was to uninstall and reinstall the plugin.

@matfish2
Copy link
Owner

matfish2 commented Dec 7, 2021

The metadata column is not added on Craft's migrations. It is part of the Install migration that instantiates the plugin. The Install migration is checking that the plugin doesn't already exist in the project config, to avoid a duplicate attempt to create the column. I am indeed puzzled as to how this should work when plugin was already installed locally and now pushed to a different environment. Will have to do some research and maybe turn to Craft for help. Will revert once I know more.

@matfish2 matfish2 self-assigned this Dec 7, 2021
@matfish2
Copy link
Owner

matfish2 commented Dec 7, 2021

Craft's response:

It looks like his deploy is missing ./craft project-config/apply.
If the plugin is already installed on one environment, it's project config that will install it on subsequent environment.
Can you ask him to try that, please?

@rostockahoi
Copy link
Author

Sorry, I omitted that part. Of course I did a ./craft project-config/apply after running the migrations. Here is the terminal output for all 3 commands.

You see that I did composer install, migrate all and project config apply. It installed your plugin when applying. After that, the error occurred.

In the second screenshot you'll see what I did next:

  • migrate again: nothing
  • install entry-meta
  • install entry-meta again (why though? :D)
  • uninstall entry-meta
  • install entry-meta: now it runs the migration

My best guess is that you should not query for plugin existence in:

if (!$this->_pluginExistsInProjectConfig() && !$this->_columnExists()) {

Querying for column existence is probably fine: While Craft takes care of migrations that were already applied via the migrations table, nobody can guarantee that this very column does not already exist on the entries table (created by someone else).

My commands

image

... here comes a lot of project config bla bla

Bildschirmfoto vom 2021-12-07 14-41-35

@matfish2
Copy link
Owner

matfish2 commented Dec 7, 2021

Thanks again :) I have removed the check and deployed a new release (1.0.1)

@matfish2 matfish2 closed this as completed Dec 7, 2021
@matfish2 matfish2 added the bug Something isn't working label Dec 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants