Skip to content

Commit 72daf69

Browse files
author
Babichev Maxim
authored
Merge pull request #48 from bavix/mariadb-10.1
add support mariadb 10.1
2 parents 5474e87 + 81ec607 commit 72daf69

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Added
9+
- Add support laravel 5.9
10+
- Add support mariadb: 5.5, 10.0+
11+
- Add support percona: 5.6
12+
- Add support mysql: 5.6
813

914
## [3.0.1] - 2019-06-17
1015
### Fixed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
],
2525
"require": {
2626
"php": "^7.1",
27-
"illuminate/database": "~5.5.0|~5.6.0|~5.7.0|~5.8.0",
27+
"illuminate/database": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|~5.9.0",
2828
"nesbot/carbon": "^1.20|^2.0",
2929
"doctrine/dbal": "^2.8",
3030
"ramsey/uuid": "^3.0"

database/migrations_v1/2018_11_06_222923_create_transactions_table.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33
use Bavix\Wallet\Models\Transaction;
44
use Illuminate\Database\Migrations\Migration;
5+
use Illuminate\Database\MySqlConnection;
56
use Illuminate\Database\Schema\Blueprint;
7+
use Illuminate\Support\Facades\DB;
68
use Illuminate\Support\Facades\Schema;
9+
use Illuminate\Database\Schema\ColumnDefinition;
710

811
class CreateTransactionsTable extends Migration
912
{
@@ -19,7 +22,7 @@ public function up(): void
1922
$table->enum('type', ['deposit', 'withdraw'])->index();
2023
$table->bigInteger('amount');
2124
$table->boolean('confirmed');
22-
$table->json('meta')->nullable();
25+
$this->json($table, 'meta')->nullable();
2326
$table->uuid('uuid')->unique();
2427
$table->timestamps();
2528

@@ -29,6 +32,28 @@ public function up(): void
2932
});
3033
}
3134

35+
/**
36+
* @param Blueprint $table
37+
* @param string $column
38+
* @return ColumnDefinition
39+
*/
40+
public function json(Blueprint $table, string $column): ColumnDefinition
41+
{
42+
$conn = DB::connection();
43+
if ($conn instanceof MySqlConnection) {
44+
$pdo = $conn->getPdo();
45+
try {
46+
$sql = 'SELECT JSON_EXTRACT(\'[10, 20, [30, 40]]\', \'$[1]\');';
47+
$prepare = $pdo->prepare($sql);
48+
$prepare->fetch();
49+
} catch (\Throwable $throwable) {
50+
return $table->text($column);
51+
}
52+
}
53+
54+
return $table->json($column);
55+
}
56+
3257
/**
3358
* @return string
3459
*/

database/migrations_v2/2018_11_19_164609_update_transactions_table.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Illuminate\Database\Schema\Blueprint;
77
use Illuminate\Support\Facades\DB;
88
use Illuminate\Support\Facades\Schema;
9+
use Illuminate\Database\SQLiteConnection;
910

1011
class UpdateTransactionsTable extends Migration
1112
{
@@ -59,6 +60,9 @@ public function up(): void
5960
public function down(): void
6061
{
6162
Schema::table($this->table(), function (Blueprint $table) {
63+
if (!(DB::connection() instanceof SQLiteConnection)) {
64+
$table->dropForeign(['wallet_id']);
65+
}
6266
$table->dropColumn('wallet_id');
6367
});
6468
}

0 commit comments

Comments
 (0)