1

Im using a multitenant package in Laravel called Laravel Tenancy and i change the setting to work with SCHEMA, every tenant has your schema right?

Well i'm using postgres and I'd like to change 'public' the default schema, i'd like to use maindatabase.

I have changed it in:

'connections' => [
        'pgsql' => [
            'driver' => 'pgsql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '5432'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'prefix_indexes' => true,
            'schema' => 'maindatabase',
            'sslmode' => 'prefer',
        ],
]

But when I execute php artisan migrate i have this error:

Illuminate\Database\QueryException : SQLSTATE[3F000]: Invalid schema name: 7 ERROR: no schema has been selected to create in at character 14 (SQL: create table "migrations" ("id" serial primary key not null, "migration" varchar(255) not null, "batch" integer not null))

How can I fix it? Thank you

6
  • see here enter link description here Commented Jul 25, 2019 at 16:15
  • There's no solution in this reference :( Commented Jul 25, 2019 at 16:25
  • do maindatabase schema already exist? Commented Jul 25, 2019 at 19:32
  • Yep..it exist @dparoli Commented Jul 25, 2019 at 21:24
  • 1
    Make sure you have all USAGE privilege to that schema. Commented Jul 25, 2019 at 21:57

1 Answer 1

2

Make sure you have all USAGE privilege to that schema, i.e.:

GRANT USAGE ON SCHEMA maindatabase TO your_username;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.