Skip to content

Connection table prefix #864

@VIPER-VLAD

Description

@VIPER-VLAD

lodata doesn't work with connection db prefix config

Repeat:

  1. Set connection prefix in config/database.php
///...
'connections' => [
      'sqlsrv' => [
          'driver' => 'sqlsrv',
          'url' => env('DB_URL'),
          'host' => env('DB_HOST', 'localhost'),
          'port' => env('DB_PORT', '1433'),
          'database' => env('DB_DATABASE', 'laravel'),
          'username' => env('DB_USERNAME', 'root'),
          'password' => env('DB_PASSWORD', ''),
          'charset' => env('DB_CHARSET', 'utf8'),
          'prefix' => 'my_prefix_', //                     <--- here
          'prefix_indexes' => true,
          'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'true'),
      ],
  ],
 ///...
  1. Setup Lodata::discover for your models in app/Providers/AppServiceProvider.php

  2. Check the error

There is no table with name "contracts" in the schema.

at vendor/doctrine/dbal/src/Schema/Exception/TableDoesNotExist.php:16
   12▕ final class TableDoesNotExist extends LogicException implements SchemaException
   13▕ {
   14▕     public static function new(string $tableName): self
   15▕     {
➜  16▕         return new self(sprintf('There is no table with name "%s" in the schema.', $tableName));
   17▕     }
   18▕ }
   19▕

prefix config was ignored. Must be my_prefix_contracts instead of contracts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions