Run your Bagisto store on MySQL, MariaDB, or PostgreSQL. Bagisto Database Compatibility is built into the core, with one codebase for all three.

The Bagisto 2.5 release in October 2026 added PostgreSQL beside MySQL and MariaDB. CI tests all three on every change.
Supporting three databases does not mean writing every query three times. Bagisto moves each difference into one known place.
The hard part was never the syntax. It was behavior that passes on one engine and fails quietly on another.
Laravel hides most differences between engines. These questions still decide whether a query works everywhere:
Take the first one. Here is the search most developers write.
|
1 2 |
// Passes on MySQL, misses matches on PostgreSQL. $query->where('name', 'like', '%'.$search.'%'); |
MySQL compares text without case under its default collations. PostgreSQL LIKE is case-sensitive.
So the same store finds the product on MySQL and returns nothing on PostgreSQL. No test fails until someone runs it there.
The Bagisto Agent Skills teach AI assistants to avoid exactly this mistake.
Bagisto answers each question with one rule, and each rule lives in one layer of the code.
The db_grammar() helper returns the SQL fragment that suits the active connection.
|
1 2 |
// Bagisto Database Compatibility: LIKE on MySQL and MariaDB, ILIKE on PostgreSQL. $query->where('name', db_grammar()->caseInsensitiveLike(), '%'.$search.'%'); |
The helper resolves the DatabaseGrammar contract. Bagisto binds a PostgreSQL grammar for pgsql connections and a MySQL grammar for the rest.
The contract holds 16 methods, one for each construct the engines spell differently:
The admin reports group sales by month, week, and day through the same grammar. One report query serves all three engines.
A blank form field arrives as an empty string. PostgreSQL rejects an empty string in an integer, date, or boolean column.
MySQL stores a boolean as TINYINT(1) and returns 1 or 0. PostgreSQL has a native boolean type and returns true or false.
Bagisto fixes both sides in the model. A setter cleans the value on write, and a cast fixes the type on read.
|
1 2 3 4 5 |
'status' => 'boolean', 'sort_order' => 'integer', $this->attributes['status'] = filter_var($value, FILTER_VALIDATE_BOOLEAN); $this->attributes['starts_from'] = $value !== '' && $value !== null ? $value : null; |
These lines come from the catalog rule model. More than 40 Bagisto models now declare boolean casts.
The rule lives in the model, not in a controller. An admin form, an import, and an API call all save the same clean value.
Bagisto records every storefront search in the search_terms table. Two shoppers can search the same new term at the same moment.
The old code tried the insert and caught the duplicate-key error.
|
1 2 3 4 5 |
try { $this->create($identity + ['results' => $results]); } catch (UniqueConstraintViolationException) { $this->addUse($identity, $results); } |
MySQL rolls back only the failed statement. PostgreSQL marks the whole transaction as failed instead.
Every later statement then fails with SQLSTATE 25P02, “current transaction is aborted”. The catch block cannot recover.
Bagisto now records the search in one statement, and the database settles the conflict itself.
|
1 2 3 4 5 |
$query->upsert( [$row], ['term', 'channel_id', 'locale'], ['uses' => $this->incrementedUses(), 'results'], ); |
Laravel compiles it to ON DUPLICATE KEY UPDATE on MySQL and MariaDB, and to ON CONFLICT DO UPDATE on PostgreSQL.
The helper incrementedUses() writes the column as search_terms.uses, because PostgreSQL reads a bare column there as ambiguous.
Each of these bugs passes every test on the database the developer runs. So CI checks Bagisto Database Compatibility on every change, on every engine.

The Pest workflow runs on each push and each pull request:
PHP 8.4 and PHP 8.5 each run against all nine images, so every change goes through 18 jobs.
The workflow does not stop at the first failure. A break on one engine leaves the others running, so one run shows every break.
Writing an extension? Follow the same rules in your own queries:
Works with Bagisto extensions:
No. Bagisto Database Compatibility is part of Bagisto core, which is open source under the MIT license.
All three pass the same test suite in CI. Pick the engine your team and your host already run well.
Run php artisan bagisto:install and select mysql, mariadb, or pgsql when it asks for the database connection.
The installer fills the default port for each, 3306 or 5432, and writes your choice to the .env file.
Yes. The production images come in one version per web server and database, such as 2.5.0-nginx-postgres.
They work when their own queries follow the same rules. An extension with MySQL-only SQL needs the grammar helper first.
Bagisto Database Compatibility comes built into Bagisto core: one codebase, typed models, and a CI matrix that proves it on three engines.
Get started today: Follow the Bagisto installation guide.
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.