Jacek Kowalski
4 hours ago 6b9278a5d57091fce636dbb640b380cfb990db6c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
declare(strict_types=1);
 
namespace App\Tests;
 
use Doctrine\DBAL\Connection;
 
/**
 * Gives a test empty legacy tables, an SQLite stand-in for orig-books.sql with the same column names and meanings.
 */
trait LegacyDatabase {
    private Connection $legacy;
 
    private function createLegacyTables(): void {
        $this->legacy = static::getContainer()->get('doctrine.dbal.legacy_connection');
        foreach (['ksiazki', 'pozycz', 'pozycz_historia', 'pozycz_missing'] as $table) {
            $this->legacy->executeStatement('DROP TABLE IF EXISTS ' . $table);
        }
 
        $this->legacy->executeStatement('CREATE TABLE ksiazki (id INTEGER PRIMARY KEY, tytul TEXT NOT NULL, autor TEXT NOT NULL, jezyk TEXT NOT NULL, rok INTEGER, miejsce TEXT, wydawnictwo TEXT, wydanie TEXT, ISBN TEXT, ISSN TEXT, regal TEXT, polka TEXT, rzad TEXT, wycofana TEXT NOT NULL DEFAULT \'0\', powod TEXT)');
        $this->legacy->executeStatement('CREATE TABLE pozycz (id INTEGER NOT NULL, kto TEXT NOT NULL, od INTEGER NOT NULL, PRIMARY KEY (id, od))');
        $this->legacy->executeStatement('CREATE TABLE pozycz_historia (id INTEGER NOT NULL, kto TEXT NOT NULL, od INTEGER NOT NULL, "do" INTEGER, PRIMARY KEY (id, od))');
    }
}