Skip to content

Commit

Permalink
debug: trace mariadb
Browse files Browse the repository at this point in the history
  • Loading branch information
WatheqAlshowaiter committed Aug 20, 2024
1 parent b334b54 commit 22a58d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/BackupTablesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ protected function backupTablesForSqlite($newTableName, $table)

protected function backupTablesForForMysqlAndMariaDb($newTableName, $table): array
{
logger('mariadb');

DB::statement(/**@lang MySQL**/ "CREATE TABLE $newTableName AS SELECT * FROM $table");

$newCreatedTables[] = $newTableName;
Expand Down
12 changes: 10 additions & 2 deletions tests/BackupTablesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,14 @@ public function test_generate_single_table_backup_all_table_data()

$this->assertTrue(Schema::hasTable($newTableName));

if(DB::getDriverName() == 'mariadb'){ // todo debugging
dump(Father::all('first_name'));
}

$this->assertEquals(Father::value('first_name'), DB::table($newTableName)->value('first_name'));
$this->assertEquals(Father::value('email'), DB::table($newTableName)->value('email'));

if (DB::getDriverName() == 'mysql' || (float) App::version() >= Constants::VERSION_AFTER_STORED_AS_VIRTUAL_AS_SUPPORT) {
if (DB::getDriverName() == 'mysql' || DB::getDriverName() == 'mariadb' || (float) App::version() >= Constants::VERSION_AFTER_STORED_AS_VIRTUAL_AS_SUPPORT) {
$this->assertEquals(Father::value('full_name'), DB::table($newTableName)->value('full_name')); // StoredAs tables
$this->assertEquals(Father::value('status'), DB::table($newTableName)->value('status')); // virtualAs tables
}
Expand Down Expand Up @@ -96,10 +100,14 @@ public function test_generate_multiple_table_backup()
$this->assertTrue(Schema::hasTable($newTableName));
$this->assertTrue(Schema::hasTable($newTableName2));

if(DB::getDriverName() == 'mariadb'){ // todo debugging
dump(Father::all('first_name'));
}

$this->assertEquals(Father::value('first_name'), DB::table($newTableName)->value('first_name'));
$this->assertEquals(Father::value('email'), DB::table($newTableName)->value('email'));

if (DB::getDriverName() == 'mysql' || (float) App::version() >= Constants::VERSION_AFTER_STORED_AS_VIRTUAL_AS_SUPPORT) {
if (DB::getDriverName() == 'mysql' || DB::getDriverName() == 'mariadb' ||(float) App::version() >= Constants::VERSION_AFTER_STORED_AS_VIRTUAL_AS_SUPPORT) {
$this->assertEquals(Father::value('full_name'), DB::table($newTableName)->value('full_name')); // StoredAs tables
$this->assertEquals(Father::value('status'), DB::table($newTableName)->value('status')); // virtualAs tables
}
Expand Down

0 comments on commit 22a58d7

Please sign in to comment.