Environment
- Docker Compose stack: packaging/docker/docker-compose.den-dev.yml
- MySQL: 8.4 (as provisioned by the compose file)
- drizzle-kit: 0.31.9
Bug 1 — drizzle-kit generates invalid SQL for MySQL prefix-length index
ee/packages/den-db/src/schema/auth.ts:207:
index("oauth_access_token_token").on(sql${table.token}(191))
drizzle-kit push fails with:
Error: You have an error in your SQL syntax ... near 'token(191))' at line 1
sql: 'CREATE INDEX oauth_access_token_token ON oauthAccessToken (``token(191));'
drizzle-kit double-wraps the already-backtick-quoted interpolated column
identifier when serializing this expression index for MySQL. Likely
affects any other prefix-length index in the schema. Workaround:
comment out the index.
Bug 2 — den service command missing --import tsx on the API start step
packaging/docker/docker-compose.den-dev.yml, den service command:
... && node /app/ee/apps/den-api/dist/main.js
With OPENWORK_DEV_MODE=1, den-api loads den-db from source (not the
built dist/) at runtime, and ee/packages/den-db/src/schema.ts does
export * from "./schema/index" without extension — which native
Node ESM resolution can't resolve without a loader. The drizzle-kit
push step in the same command already uses --import tsx, but the
second node invocation doesn't, causing:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module
'/app/ee/packages/den-db/src/schema/index' imported from
/app/ee/packages/den-db/src/schema.ts
Fix: add --import tsx to the second node invocation too:
... && node --import tsx /app/ee/apps/den-api/dist/main.js
(Note: adding a .ts extension to the schema.ts import instead breaks
the tsup build step with TS5097, so the compose command is the
correct place to fix this, not the schema import.)
Result
With both fixes applied, docker compose -f packaging/docker/docker-compose.den-dev.yml up
starts mysql, den, and web cleanly.
Environment
Bug 1 — drizzle-kit generates invalid SQL for MySQL prefix-length index
ee/packages/den-db/src/schema/auth.ts:207:
index("oauth_access_token_token").on(sql
${table.token}(191))drizzle-kit push fails with:
Error: You have an error in your SQL syntax ... near 'token
(191))' at line 1sql: 'CREATE INDEX
oauth_access_token_tokenONoauthAccessToken(``token(191));'drizzle-kit double-wraps the already-backtick-quoted interpolated column
identifier when serializing this expression index for MySQL. Likely
affects any other prefix-length index in the schema. Workaround:
comment out the index.
Bug 2 — den service command missing --import tsx on the API start step
packaging/docker/docker-compose.den-dev.yml,
denservice command:... && node /app/ee/apps/den-api/dist/main.js
With OPENWORK_DEV_MODE=1, den-api loads den-db from source (not the
built dist/) at runtime, and ee/packages/den-db/src/schema.ts does
export * from "./schema/index"without extension — which nativeNode ESM resolution can't resolve without a loader. The drizzle-kit
push step in the same command already uses --import tsx, but the
second
nodeinvocation doesn't, causing:Error [ERR_MODULE_NOT_FOUND]: Cannot find module
'/app/ee/packages/den-db/src/schema/index' imported from
/app/ee/packages/den-db/src/schema.ts
Fix: add --import tsx to the second node invocation too:
... && node --import tsx /app/ee/apps/den-api/dist/main.js
(Note: adding a .ts extension to the schema.ts import instead breaks
the tsup build step with TS5097, so the compose command is the
correct place to fix this, not the schema import.)
Result
With both fixes applied,
docker compose -f packaging/docker/docker-compose.den-dev.yml upstarts mysql, den, and web cleanly.