bcc-code / directus-schema-sync

The better way to sync your Directus schema and data between environments
Apache License 2.0
90 stars 4 forks source link

ER_BAD_FIELD_ERROR: Unknown column 'mv_locked' in 'where clause' #9

Closed crebuh closed 5 months ago

crebuh commented 6 months ago

Describe the Bug

Hello,

I tried to use the sync extensions, but after installation it throws an error.

To Reproduce

[10:42:41.375] WARN: select from directus_settings where id = 1 and mv_locked = false and not mv_hash = 'bfaa29f6679e2da0a3cb26cb6ff9f93cd81a49df618dcf8bd156236ef542ffad' and mv_ts < '2023-12-18 10:39:49' for update - ER_BAD_FIELD_ERROR: Unknown column 'mv_locked' in 'where clause' err: { "type": "Error", "message": "select from directus_settings where id = 1 and mv_locked = false and not mv_hash = 'bfaa29f6679e2da0a3cb26cb6ff9f93cd81a49df618dcf8bd156236ef542ffad' and mv_ts < '2023-12-18 10:39:49' for update - ER_BAD_FIELD_ERROR: Unknown column 'mv_locked' in 'where clause'", "stack": Error: ER_BAD_FIELD_ERROR: Unknown column 'mv_locked' in 'where clause' at Sequence._packetToError (/directus/node_modules/.pnpm/mysql@2.18.1/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14) at Query.ErrorPacket (/directus/node_modules/.pnpm/mysql@2.18.1/node_modules/mysql/lib/protocol/sequences/Query.js:79:18) at Protocol._parsePacket (/directus/node_modules/.pnpm/mysql@2.18.1/node_modules/mysql/lib/protocol/Protocol.js:291:23) at Parser._parsePacket (/directus/node_modules/.pnpm/mysql@2.18.1/node_modules/mysql/lib/protocol/Parser.js:433:10) at Parser.write (/directus/node_modules/.pnpm/mysql@2.18.1/node_modules/mysql/lib/protocol/Parser.js:43:10) at Protocol.write (/directus/node_modules/.pnpm/mysql@2.18.1/node_modules/mysql/lib/protocol/Protocol.js:38:16) at Socket. (/directus/node_modules/.pnpm/mysql@2.18.1/node_modules/mysql/lib/Connection.js:88:28) at Socket. (/directus/node_modules/.pnpm/mysql@2.18.1/node_modules/mysql/lib/Connection.js:526:10) at Socket.emit (node:events:517:28) at addChunk (node:internal/streams/readable:335:12)

          at Protocol._enqueue (/directus/node_modules/.pnpm/mysql@2.18.1/node_modules/mysql/lib/protocol/Protocol.js:144:48)
          at Connection.query (/directus/node_modules/.pnpm/mysql@2.18.1/node_modules/mysql/lib/Connection.js:198:25)
          at /directus/node_modules/.pnpm/knex@2.4.2_mysql@2.18.1_pg@8.11.0_sqlite3@5.1.6_tedious@16.1.0/node_modules/knex/lib/dialects/mysql/index.js:132:18
          at new Promise (<anonymous>)
          at Client_MySQL._query (/directus/node_modules/.pnpm/knex@2.4.2_mysql@2.18.1_pg@8.11.0_sqlite3@5.1.6_tedious@16.1.0/node_modules/knex/lib/dialects/mysql/index.js:126:12)
          at executeQuery (/directus/node_modules/.pnpm/knex@2.4.2_mysql@2.18.1_pg@8.11.0_sqlite3@5.1.6_tedious@16.1.0/node_modules/knex/lib/execution/internal/query-executioner.js:37:17)
          at Client_MySQL.query (/directus/node_modules/.pnpm/knex@2.4.2_mysql@2.18.1_pg@8.11.0_sqlite3@5.1.6_tedious@16.1.0/node_modules/knex/lib/client.js:146:12)
          at /directus/node_modules/.pnpm/knex@2.4.2_mysql@2.18.1_pg@8.11.0_sqlite3@5.1.6_tedious@16.1.0/node_modules/knex/lib/execution/transaction.js:363:24
          at new Promise (<anonymous>)
          at trxClient.query (/directus/node_modules/.pnpm/knex@2.4.2_mysql@2.18.1_pg@8.11.0_sqlite3@5.1.6_tedious@16.1.0/node_modules/knex/lib/execution/transaction.js:358:12)
  "code": "ER_BAD_FIELD_ERROR",
  "errno": 1054,
  "sqlMessage": "Unknown column 'mv_locked' in 'where clause'",
  "sqlState": "42S22",
  "index": 0,
  "sql": "select * from `directus_settings` where `id` = 1 and `mv_locked` = false and not `mv_hash` = 'bfaa29f6679e2da0a3cb26cb6ff9f93cd81a49df618dcf8bd156236ef542ffad' and `mv_ts` < '2023-12-18 10:39:49' for update"
}

When I'm doing a manual import/export I've removed the 'mv_locked' entry from the directus_config.js then it is working.

Version

10.8.2

Installed Extension Via

Docker file

crebuh commented 6 months ago

I have to correct this, the error is thrown when I want to export data and the schema, when I just use export-schema it is working. So it has nothing to do with the entries inside directus_config.js

u12206050 commented 6 months ago

I have seen instances when an import fails and the command crashes such that it wasn't able to unlock the task eg. mv_locked to false. So then you'd have to set it to false manually.

The original error does seem to be though that the schema-sync install didn't run successfully since the columns didn't exist. Have you checked that they are indeed in the directus_settings table?

crebuh commented 5 months ago

@u12206050

Yes you are right, i checked the tables again and the columns were not added to directus_settings. I was not aware, that extensions are also extending base directus tables ... I rerun the install command and now it is working :)