Skip to content

fix(stubs): detect actual database connection name - #10

Open
guoyunhe wants to merge 1 commit into
adonisjs:0.xfrom
guoyunhe:database-connection
Open

guoyunhe wants to merge 1 commit into
adonisjs:0.xfrom
guoyunhe:database-connection

Conversation

@guoyunhe

Copy link
Copy Markdown

🔗 Linked issue

❓ Type of change

  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

node ace add @adonisjs/queue will create a broken config:

// config/queue.ts
import env from '#start/env'
import { defineConfig, drivers } from '@adonisjs/queue'

export default defineConfig({
  default: env.get('QUEUE_DRIVER', 'database'),

  adapters: {
    database: drivers.database({
      connectionName: 'primary',
    }),
    sync: drivers.sync(),
  },

  worker: {
    concurrency: 5,
    idleDelay: '2s',
  },

  locations: ['./app/jobs/**/*.{ts,js}'],
})

database doesn't have a primary connection. app will fail to start.

The solution is to add detection logic, set connectionName to match actual connection from config/database.ts, and fallback to sqlite.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant