From ac960a1dcbda131b3262cbf04423d4d85c906ed5 Mon Sep 17 00:00:00 2001 From: Hafez Divandari Date: Thu, 28 Dec 2023 20:08:47 +0330 Subject: [PATCH] [10.x] Include system versioned tables for MariaDB (#49509) * include system versioned tables for mariadb * fix tests * wip --- .../Database/Schema/Grammars/MySqlGrammar.php | 2 +- .../Integration/Database/SchemaBuilderTest.php | 17 +++++++++++++++++ 2 files changed, 18 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..7f3c8546881f 100644 --- a/tests/Integration/Database/SchemaBuilderTest.php +++ b/tests/Integration/Database/SchemaBuilderTest.php @@ -367,4 +367,21 @@ public function testGetCompoundForeignKeys() && $foreign['foreign_columns'] === ['b', 'a'] )); } + + public function testSystemVersionedTables() + { + if ($this->driver !== 'mysql' || ! $this->getConnection()->isMaria()) { + $this->markTestSkipped('Test requires a MariaDB connection.'); + } + + 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;'); + } }