Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 484 Vote(s) - 3.42 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PostgreSQL error when run migration Lumen/Laravel

#1
I recently changed the way my application connects to my PostgreSQL database to add the [read/write][1] principle. Since then, when I launch a migration I get the following error:

```
In Connection.php line 463:

[PDOException (42601)]
SQLSTATE[42601]: Syntax error: 7 ERROR: zero-length delimited identifier at or near """"
LINE 1: create table "" ("id" serial primary key not null, "migratio...
^
```

when I delete the database.php file, my migrations work correctly.

My .env

```
DB_CONNECTION=pgsql
DB_HOST=192.168.1.1
DB_PORT=5432
DB_DATABASE=database
DB_USERNAME=user
DB_PASSWORD=password

DB_USERNAME_READ=user
DB_PASSWORD_READ=password
```

My database.php
```php
<?php

return [

'default' => env('DB_CONNECTION', 'pgsql'),

'connections' => [
'pgsql' => [
'read' => [
'username' => env('DB_USERNAME_READ'),
'password' => env('DB_PASSWORD_READ'),
],
'write' => [
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),
],
'sticky' => true,
'driver' => 'pgsql',
'host' => env('DB_HOST'),
'database' => env('DB_DATABASE'),
],
],
];
```

and one of my migrations:
```php
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateGameUserTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('game_user', function (Blueprint $table) {
$table->bigInteger('game_id');
$table->bigInteger('user_id');
$table->foreign('game_id')->references('id')->on('games');
$table->foreign('user_id')->references('id')->on('users');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('game_user');
}
}
```

- PHP 7.3.13
- Lumen 6.3.3
- PostegreSQL 9.6.2

[1]:

[To see links please register here]

Reply

#2
Lumen doesn't come with a `config/database.php` file by default. You can either copy a default Laravel file, or create your own with your own settings.

If you've already added your own custom file, it looks like you need to specify the migrations table name.

Default entry for Laravel is `'migrations' => 'migrations'`, but of course you can name it whatever you like.
Reply

#3
I got the same problem on a Laravel 7.x project.
My solution was to remove the cache of my application then to update my dependencies via composer:

```
php artisan cache:clear
composer update
```
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through