laravel icon indicating copy to clipboard operation
laravel copied to clipboard

How to change postgres schema?

Open HoangBee102 opened this issue 4 years ago • 3 comments

I have databases in postgres with multi schema and i want change schema to "current" from default "public". When i run: php artisan code:models => model on schema public, but i want creat on schema "current". Pls help me!

HoangBee102 avatar Dec 08 '20 08:12 HoangBee102

Have you tried php artisan code:models --schema=current?

CristianLlanos avatar Dec 08 '20 15:12 CristianLlanos

I have tried, but it don't work!

HoangBee102 avatar Dec 09 '20 01:12 HoangBee102

I have the same issue.

File: src/Meta/Postgres/Schema.php Missing $schema parameter.

You need to replace 'public' to $this->schema

here

    /**
     * @param string $schema
     *
     * @return array
     */
    protected function fetchTables()
    {
        $rows = $this->arraify($this->connection->select(
            'SELECT * FROM pg_tables where schemaname=\'public\''
        ));
        $names = array_column($rows, 'tablename');

        return Arr::flatten($names);
    }

and here

/**
     * @param \Reliese\Meta\Blueprint $blueprint
     */
    protected function fillColumns(Blueprint $blueprint)
    {
        $rows = $this->arraify($this->connection->select(
            'SELECT * FROM information_schema.columns '.
            'WHERE table_schema=\'public\''.
            'AND table_name='.$this->wrap($blueprint->table())
        ));
        foreach ($rows as $column) {
            $blueprint->withColumn(
                $this->parseColumn($column)
            );
        }
    }

maltf0 avatar May 26 '21 11:05 maltf0