Skip to content
This repository was archived by the owner on Feb 16, 2022. It is now read-only.

Commit fc04fe8

Browse files
committed
Drop old MySQL versions support that doesn't support json columns
1 parent d06253f commit fc04fe8

5 files changed

+5
-75
lines changed

database/migrations/2020_01_01_000001_create_statistics_data_table.php

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public function up(): void
2323
$table->integer('status_code');
2424
$table->text('uri');
2525
$table->string('method');
26-
$table->{$this->jsonable()}('server');
27-
$table->{$this->jsonable()}('input')->nullable();
26+
$table->json('server');
27+
$table->json('input')->nullable();
2828
$table->timestamp('created_at')->nullable();
2929
});
3030
}
@@ -38,18 +38,4 @@ public function down(): void
3838
{
3939
Schema::dropIfExists(config('rinvex.statistics.tables.data'));
4040
}
41-
42-
/**
43-
* Get jsonable column data type.
44-
*
45-
* @return string
46-
*/
47-
protected function jsonable(): string
48-
{
49-
$driverName = DB::connection()->getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME);
50-
$dbVersion = DB::connection()->getPdo()->getAttribute(PDO::ATTR_SERVER_VERSION);
51-
$isOldVersion = version_compare($dbVersion, '5.7.8', 'lt');
52-
53-
return $driverName === 'mysql' && $isOldVersion ? 'text' : 'json';
54-
}
5541
}

database/migrations/2020_01_01_000002_create_statistics_routes_table.php

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function up(): void
2222
$table->string('path');
2323
$table->string('action');
2424
$table->string('middleware')->nullable();
25-
$table->{$this->jsonable()}('parameters')->nullable();
25+
$table->json('parameters')->nullable();
2626
$table->integer('count')->unsigned()->default(0);
2727

2828
// Indexes
@@ -39,18 +39,4 @@ public function down(): void
3939
{
4040
Schema::dropIfExists(config('rinvex.statistics.tables.routes'));
4141
}
42-
43-
/**
44-
* Get jsonable column data type.
45-
*
46-
* @return string
47-
*/
48-
protected function jsonable(): string
49-
{
50-
$driverName = DB::connection()->getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME);
51-
$dbVersion = DB::connection()->getPdo()->getAttribute(PDO::ATTR_SERVER_VERSION);
52-
$isOldVersion = version_compare($dbVersion, '5.7.8', 'lt');
53-
54-
return $driverName === 'mysql' && $isOldVersion ? 'text' : 'json';
55-
}
5642
}

database/migrations/2020_01_01_000003_create_statistics_paths_table.php

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function up(): void
2222
$table->string('locale');
2323
$table->string('path');
2424
$table->string('method');
25-
$table->{$this->jsonable()}('parameters')->nullable();
25+
$table->json('parameters')->nullable();
2626
$table->integer('count')->unsigned()->default(0);
2727

2828
// Indexes
@@ -39,18 +39,4 @@ public function down(): void
3939
{
4040
Schema::dropIfExists(config('rinvex.statistics.tables.paths'));
4141
}
42-
43-
/**
44-
* Get jsonable column data type.
45-
*
46-
* @return string
47-
*/
48-
protected function jsonable(): string
49-
{
50-
$driverName = DB::connection()->getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME);
51-
$dbVersion = DB::connection()->getPdo()->getAttribute(PDO::ATTR_SERVER_VERSION);
52-
$isOldVersion = version_compare($dbVersion, '5.7.8', 'lt');
53-
54-
return $driverName === 'mysql' && $isOldVersion ? 'text' : 'json';
55-
}
5642
}

database/migrations/2020_01_01_000007_create_statistics_geoips_table.php

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function up(): void
2222
$table->string('latitude');
2323
$table->string('longitude');
2424
$table->char('country_code', 2);
25-
$table->{$this->jsonable()}('client_ips')->nullable();
25+
$table->json('client_ips')->nullable();
2626
$table->boolean('is_from_trusted_proxy')->default(0);
2727
$table->string('division_code')->nullable();
2828
$table->string('postal_code')->nullable();
@@ -44,18 +44,4 @@ public function down(): void
4444
{
4545
Schema::dropIfExists(config('rinvex.statistics.tables.geoips'));
4646
}
47-
48-
/**
49-
* Get jsonable column data type.
50-
*
51-
* @return string
52-
*/
53-
protected function jsonable(): string
54-
{
55-
$driverName = DB::connection()->getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME);
56-
$dbVersion = DB::connection()->getPdo()->getAttribute(PDO::ATTR_SERVER_VERSION);
57-
$isOldVersion = version_compare($dbVersion, '5.7.8', 'lt');
58-
59-
return $driverName === 'mysql' && $isOldVersion ? 'text' : 'json';
60-
}
6147
}

database/migrations/2020_01_01_000008_create_statistics_requests_table.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,4 @@ public function down(): void
6363
{
6464
Schema::dropIfExists(config('rinvex.statistics.tables.requests'));
6565
}
66-
67-
/**
68-
* Get jsonable column data type.
69-
*
70-
* @return string
71-
*/
72-
protected function jsonable(): string
73-
{
74-
$driverName = DB::connection()->getPdo()->getAttribute(PDO::ATTR_DRIVER_NAME);
75-
$dbVersion = DB::connection()->getPdo()->getAttribute(PDO::ATTR_SERVER_VERSION);
76-
$isOldVersion = version_compare($dbVersion, '5.7.8', 'lt');
77-
78-
return $driverName === 'mysql' && $isOldVersion ? 'text' : 'json';
79-
}
8066
}

0 commit comments

Comments
 (0)