From 312bfd2c146bcf855512830f959eae7534f2ec23 Mon Sep 17 00:00:00 2001 From: Hafez Divandari Date: Thu, 28 Dec 2023 17:35:25 +0330 Subject: [PATCH 1/3] include system versioned tables for mariadb --- .../Database/Schema/Grammars/MySqlGrammar.php | 2 +- tests/Integration/Database/SchemaBuilderTest.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php b/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php index 1f64a7c25aa7..d54e9a6fe218 100755 --- a/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php +++ b/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php @@ -88,7 +88,7 @@ public function compileTables($database) return sprintf( 'select table_name as `name`, (data_length + index_length) as `size`, ' .'table_comment as `comment`, engine as `engine`, table_collation as `collation` ' - ."from information_schema.tables where table_schema = %s and table_type = 'BASE TABLE' " + ."from information_schema.tables where table_schema = %s and table_type in ('BASE TABLE', 'SYSTEM VERSIONED') " .'order by table_name', $this->quoteString($database) ); diff --git a/tests/Integration/Database/SchemaBuilderTest.php b/tests/Integration/Database/SchemaBuilderTest.php index 456e382fd964..f24beb1714b0 100644 --- a/tests/Integration/Database/SchemaBuilderTest.php +++ b/tests/Integration/Database/SchemaBuilderTest.php @@ -367,4 +367,19 @@ public function testGetCompoundForeignKeys() && $foreign['foreign_columns'] === ['b', 'a'] )); } + + public function testSystemVersionTables() + { + var_dump($this->driver); + + DB::statement('create table `test` (`foo` int) WITH system versioning;'); + + $this->assertTrue(Schema::hasTable('test')); + + Schema::dropAllTables(); + + $this->artisan('migrate:install'); + + DB::statement('create table `test` (`foo` int) WITH system versioning;'); + } } From 6ed6638ea2a7126f72070659b5d4595e9d77550c Mon Sep 17 00:00:00 2001 From: Hafez Divandari Date: Thu, 28 Dec 2023 17:41:12 +0330 Subject: [PATCH 2/3] fix tests --- tests/Integration/Database/SchemaBuilderTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/Integration/Database/SchemaBuilderTest.php b/tests/Integration/Database/SchemaBuilderTest.php index f24beb1714b0..a81c73de3e4c 100644 --- a/tests/Integration/Database/SchemaBuilderTest.php +++ b/tests/Integration/Database/SchemaBuilderTest.php @@ -370,7 +370,9 @@ public function testGetCompoundForeignKeys() public function testSystemVersionTables() { - var_dump($this->driver); + if ($this->driver !== 'mysql' || ! $this->getConnection()->isMaria()) { + $this->markTestSkipped('Test requires a MariaDB connection.'); + } DB::statement('create table `test` (`foo` int) WITH system versioning;'); From e8be7fe18755b10a6931918be3d2a79c3c972d01 Mon Sep 17 00:00:00 2001 From: Hafez Divandari Date: Thu, 28 Dec 2023 17:41:51 +0330 Subject: [PATCH 3/3] wip --- tests/Integration/Database/SchemaBuilderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Integration/Database/SchemaBuilderTest.php b/tests/Integration/Database/SchemaBuilderTest.php index a81c73de3e4c..7f3c8546881f 100644 --- a/tests/Integration/Database/SchemaBuilderTest.php +++ b/tests/Integration/Database/SchemaBuilderTest.php @@ -368,7 +368,7 @@ public function testGetCompoundForeignKeys() )); } - public function testSystemVersionTables() + public function testSystemVersionedTables() { if ($this->driver !== 'mysql' || ! $this->getConnection()->isMaria()) { $this->markTestSkipped('Test requires a MariaDB connection.');