umbrellio / laravel-pg-extensions Goto Github PK
View Code? Open in Web Editor NEWLaravel extensions for Postgres
License: MIT License
Laravel extensions for Postgres
License: MIT License
Было бы круто по аналогии с tsrange добавить возможность создавать колонку int4range
example:
Schema::table('table', function (Blueprint $table) {
$table->string('code');
$table->tinyInteger('enabled', 1)->unsigned()->default(1);
$table->unique(['code'])->where(['enabled' => 1]);
});
What parameters should be able to customize:
How it can be used:
Schema::table('table', function (Blueprint $table) {
...
$table->createTrigger($name)
->before() // or ->after() // and by default 'BEFORE'
->event('INSERT') // or ->event(['INSERT', 'UPDATE']) // and by default INSERT
->language() // by default 'plpgsql'
->declare([
'delta_time_key' => 'integer',
'delta_amount_sold' => 'numeric(15,2)',
]) // and by default is empty []
->body($statement, $bindings = []) // and by default body is empty, $bindings is empty
;
});
WDYT about these tags ("github search SEO"):
laravel
laravel-pg
laravel-pg-driver
postgres
pg
postgresql
As per pull request #48864 in Laravel, Laravel has abandoned its dependency on DBAL (Database Abstraction Layer) during the migration to 11.x.
In the process, methods related to Doctrine that were implemented in Illuminate\Database\Connection::class have also been removed.
Although this library was recently updated to support Laravel 11.x and its major version was bumped to 6, it still seems to be using methods like DB::registerDoctrineType(), which suggests that it has not actually followed the changes made in Laravel 11.x.
The issue is that non-existent methods continue to be called from the DB Facade, causing the resolution of the Connection to recurse infinitely, which leads to the processing getting stuck.
Thanks.
I trying to change column type and convert columns values.
I can't put USING statement in blueprint methods.
Sample SQL request:
#title is varchar
ALTER TABLE posts ALTER COLUMN title TYPE json USING ('{"en":"' || title || '"}')::json
i can now only put it in DB::statement . : (
i want get something like following:
Schema::table('posts', function (Blueprint $table) {
$table->json('title')->using($expression)->change();
});
Hi! When a set a pg partition like this:
Schema::table('pedidos', function (Blueprint $table) {
$table->attachPartition('data_emissao')->range(
[
"from" => "2010-01-01",
"to" => "2010-12-31"
]
);
});
i give this error:
SQLSTATE[42P17]: Invalid object definition: 7 ERROR: table "pedidos" is not partitioned (SQL: alter table "pedidos" attach partition data_emissao for values from (2010-01-01) to (2010-12-31))
Is any plans to implement array types ?
How to use, example:
Schema::table('some_table', function (Blueprint $table) {
$table->integer('code')
->default(DB::raw("''::character varying"))
->change();
...
$table->bigInteger('id')
->default(DB::raw("nextval('some_table_id_seq'::regclass)")
->change();
});
Now there are some problems, since AbstractPlatform generates incorrect SQL for ALTER TABLE, ex.:
Schema::table('some_table', function (Blueprint $table) {
$table->integer('code')
->default(DB::raw("''::character varying"))
->change();
});
Results:
ALTER TABLE some_table ALTER COLUMN code SET DEFAULT '\'\'::character varying'::character varying
Expected:
ALTER TABLE some_table ALTER COLUMN code SET DEFAULT ''::character varying
Depends on: doctrine/dbal#3626
I'm waiting for the merge request to be merged to continue working...
To begin this extension:
https://www.postgresql.org/docs/11/ltree.html
Also, to do think a mechanism for registering custom Doctrine types in PostgresConnection on example "ltree".
When we batch insert into postgres database table, we can get an option by postgres to return all the inserted IDs.
INSERT INTO ycode_entities (name, email, created_at) VALUES [(...)]
RETURNING id
The above statement will retrieve all the Id that has been inserted in bulk.
Unfortunately, there is no option to do this natively without using raw query in Laravel since insertMany()
doesn't return ids or any primary key data.
Is there a way to extend this functionality using laravel-pg-extensions
or by any means?
Due to how my environment is setup the host name wont be reachable, ideally it shouldn't try to connect at all when discovering the package.
Nothing to install, update or remove
Generating autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> rm -f laravel/bootstrap/cache/services.php
> rm -f laravel/bootstrap/cache/packages.php
> @php laravel/artisan package:discover
Doctrine\DBAL\Driver\PDOException
SQLSTATE[08006] [7] could not translate host name "pgbouncer" to address: Temporary failure in name resolution
at vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:31
27▕ parent::__construct($dsn, (string) $user, (string) $password, (array) $options);
28▕ $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, [PDOStatement::class, []]);
29▕ $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
30▕ } catch (\PDOException $exception) {
➜ 31▕ throw new PDOException($exception);
32▕ }
33▕ }
34▕
35▕ /**
1 [internal]:0
Illuminate\Foundation\Application::Illuminate\Foundation\{closure}()
+15 vendor frames
17 laravel/app/Providers/DatabaseServiceProvider.php:42
Illuminate\Database\Connection::__construct()
At our team, we are trying to use umbrellio/laravel-ltree on a laravel project.
Currently all tests are using an on memory sqlite database connection.
From the moment we added laravel-ltree extension, all tests started to fail as every connection started to be made using class Umbrellio\Postgres\PostgresConnection.
Is there any way I can chose when to use this class or not to handle my database connections?
Thank you,
Filipe
Hi,
Is there a reason for not handling resource types when PDO::ATTR_EMULATE_PREPARES is set ?
I believe this should be added to the bindValues switch statement, to be in-line with laravel ?
case is_resource($value):
$dataType = PDO::PARAM_LOB;
break;
https://github.com/umbrellio/laravel-pg-extensions/blob/master/src/PostgresConnection.php#L82
https://github.com/laravel/framework/blob/10.x/src/Illuminate/Database/Connection.php#L721
When i use attach i give an error 'table is not partitioned'.
How can we define partitioned table at migrations?
I have a problem, I use master and slave postgres. master is located far from the backend, and slave is nearby. This package is automatically connected by default to the master - write connection, thereby increasing the request time by more than 2 seconds! How can I fix this? Please help me.
After remove umbrellio/laravel-pg-extensions, all ok!
stack trace:
PDO::__construct
Illuminate\Database\Connectors\Connector::createPdoConnection
Illuminate\Database\Connectors\Connector::createConnection
Illuminate\Database\Connectors\PostgresConnector::connect
Illuminate\Database\Connectors\ConnectionFactory::Illuminate\Database\Connectors{closure}
call_user_func
Illuminate\Database\Connection::getPdo
Illuminate\Database\Connection::getDoctrineConnection
Umbrellio\Postgres\PostgresConnection::getDoctrineConnection
Illuminate\Database\Connection::getDoctrineSchemaManager
Illuminate\Database\Schema\Builder::registerCustomDoctrineType
Umbrellio\Postgres\PostgresConnection::Umbrellio\Postgres{closure}
Illuminate\Support\Collection::each
Umbrellio\Postgres\PostgresConnection::registerExtensions
Umbrellio\Postgres\PostgresConnection::useDefaultPostProcessor
Illuminate\Database\Connection::__construct
Umbrellio\Postgres\Connectors\ConnectionFactory::createConnection
Illuminate\Database\Connectors\ConnectionFactory::createSingleConnection
Illuminate\Database\Connectors\ConnectionFactory::createReadWriteConnection
Illuminate\Database\Connectors\ConnectionFactory::make
/**
* Determine if the given view exists.
*
* @param string $view
* @return bool
*/
public function hasView($view)
{
$view = $this->connection->getTablePrefix().$view;
foreach ($this->getViews() as $value) {
if (strtolower($view) === strtolower($value['name'])) {
return true;
}
}
return false;
}
public function hasView(string $view): bool
{
return count($this->connection->selectFromWriteConnection($this->grammar->compileViewExists(), [
$this->connection->getConfig()['schema'],
$this->connection->getTablePrefix() . $view,
])) > 0;
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.