Skip to content

Commit 13d3e3d

Browse files
fix: change concat string function in sqlite
1 parent 5ed6a68 commit 13d3e3d

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

database/migrations/2024_07_13_090447_create_fathers_table.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ public function up(): void
1616
$table->string('first_name'); // required
1717
$table->string('last_name'); // required
1818
$table->string('email'); // required
19-
$table->string('full_name')->storedAs("CONCAT(first_name, ' ', last_name)"); // Correct SQL syntax for stored column
20-
$table->timestamps(); // created_at, updated_at => ignored because they are nullable
19+
if (DB::getDriverName() === 'sqlite') {
20+
$table->string('full_name')->storedAs("first_name || ' ' || last_name"); // SQLite concatenation
21+
} else {
22+
$table->string('full_name')->storedAs("CONCAT(first_name, ' ', last_name)"); // MySQL syntax
23+
} $table->timestamps(); // created_at, updated_at => ignored because they are nullable
2124
});
2225
}
2326

src/BackupTablesService.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected function processBackup(array $tablesToBackup = [])
8181
$this->backupTablesForForPostgres($newTableName, $table);
8282
break;
8383
case 'sqlsrv':
84-
return $this->backupTablesForForSqlServer($newTableName, $table);
84+
$this->backupTablesForForSqlServer($newTableName, $table);
8585
break;
8686
default:
8787
throw Exception('NOT SUPPORTED DATABASE DRIVER');

src/Models/Father.php

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace WatheqAlshowaiter\BackupTablesServiceProvider\Models;
44

55
use Illuminate\Database\Eloquent\Model;
6-
use WatheqAlshowaiter\ModelRequiredFields\RequiredFields;
76

87

98
class Father extends Model

0 commit comments

Comments
 (0)