-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathVersion20251028092901MySqlInit.php
More file actions
47 lines (40 loc) · 1.3 KB
/
Version20251028092901MySqlInit.php
File metadata and controls
47 lines (40 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
declare(strict_types=1);
namespace PhpList\Core\Migrations;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Manual Migration
*/
final class Version20251028092901MySqlInit extends AbstractMigration
{
public function getDescription(): string
{
return 'Initial schema from SQL file generated from phplist3';
}
public function up(Schema $schema): void
{
$platform = $this->connection->getDatabasePlatform();
$this->skipIf(
!$platform instanceof MySQLPlatform,
sprintf(
'This migration is only applicable for MySQL. Current platform: %s',
get_class($platform)
)
);
$schemaManager = $this->connection->createSchemaManager();
$tables = $schemaManager->listTableNames();
$hasUserStats = array_filter(
$tables,
static fn (string $table): bool =>
str_ends_with($table, 'userstats')
);
$this->skipIf(
!empty($hasUserStats),
'phpList schema already exists.'
);
// this up() migration is auto-generated, please modify it to your needs
$this->addSql(file_get_contents(__DIR__.'/initial_schema.sql'));
}
}