Skip to content

[Bug]: DatabaseDriver becomes wrong driver #83

@simonankele

Description

@simonankele

What happened?

I have three databases, which I have specified separately as connections in database.php.
php artisan model:show specifies the database, which is the connection. This means that the database is unfortunately defined as a connection in the SchemaModel class $data['database'].

I have corrected this for myself as follows (SchemaModel):

$connection = config('database.connections.' . $data['database']);

        $self = new self(
            $schemaClass,
            $data['class'],
            $connection['driver'],
            $data['table'],
            $data['policy'] ?? null,
            [],
            [],
            $data['observers'] ?? [],
        );

How to reproduce the bug

  1. Creating second database
  2. Add additional connection 'second_connection' in the database.php for the new database
  3. Set $connection to 'second_connection' in the Model
/**
     * The database connection that should be used by the model.
     *
     * @var string
     */
    protected $connection = 'second_connection';
  1. Run php artisan typescriptable
  2. Error because $databaseDriver 'second_connection' is not an Enum in the DatabaseDriverEnum

Package Version

3.1

PHP Version

8.3

Which operating systems does with happen with?

Linux

Notes

Sorry for bad bug report - it's my first ;-)

Metadata

Metadata

Labels

bugSomething isn't workingenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions