Skip to content

Commit c6cd7d8

Browse files
authored
Merge pull request #6015 from pmattmann/feature/insert-prototype-checklist
Checklist: add pbs-checklist (basis, aufbau, wolf, pfadi)
2 parents 025cca1 + e4555ed commit c6cd7d8

File tree

3 files changed

+222
-0
lines changed

3 files changed

+222
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DoctrineMigrations;
6+
7+
use Doctrine\DBAL\Schema\Schema;
8+
use Doctrine\Migrations\AbstractMigration;
9+
10+
require_once __DIR__.'/checklists/helpers.php';
11+
12+
/**
13+
* Auto-generated Migration: Please modify to your needs!
14+
*/
15+
final class Version20240928090159 extends AbstractMigration {
16+
public function getDescription(): string {
17+
return 'Insert PBS-Checklist';
18+
}
19+
20+
public function up(Schema $schema): void {
21+
$statements = getStatementsForMigrationFile(__DIR__.'/checklists/pbs-checklist.sql');
22+
foreach ($statements as $statement) {
23+
if (trim($statement)) {
24+
$this->addSql($statement);
25+
}
26+
}
27+
}
28+
29+
public function down(Schema $schema): void {}
30+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace DoctrineMigrations;
4+
5+
use PhpMyAdmin\SqlParser\Parser;
6+
use PhpMyAdmin\SqlParser\Statement;
7+
8+
function getStatementsForMigrationFile(string $sqlFile): array {
9+
$sql = file_get_contents($sqlFile);
10+
11+
$parser = new Parser($sql);
12+
$parsed_statements = array_map(fn (Statement $statement) => $statement->build(), $parser->statements);
13+
14+
return str_replace('`', '"', $parsed_statements);
15+
}

0 commit comments

Comments
 (0)