-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathVersion20180624103144.php
44 lines (38 loc) · 2.06 KB
/
Version20180624103144.php
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
<?php
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Description : Create application schema
*/
final class Version20180624103144 extends AbstractMigration
{
public function up(Schema $schema) : void
{
$this->abortIf(
$this->connection->getDatabasePlatform()->getName() !== 'sqlite',
'Migration can only be executed safely on \'sqlite\'.'
);
$this->addSql('CREATE TABLE person (id CLOB NOT NULL, animal_id CLOB DEFAULT NULL, name CLOB NOT NULL, title TEXT NOT NULL, birth_date DATETIME NOT NULL, created_at DATETIME NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_34DCD1768E962C16 ON person (animal_id)');
$this->addSql('CREATE UNIQUE INDEX person_idx ON person (id)');
$this->addSql('CREATE TABLE person_has_vehicle (person_id CLOB NOT NULL, vehicle_id CLOB NOT NULL, PRIMARY KEY(person_id, vehicle_id))');
$this->addSql('CREATE INDEX IDX_119AD3D5217BBB47 ON person_has_vehicle (person_id)');
$this->addSql('CREATE INDEX IDX_119AD3D5545317D1 ON person_has_vehicle (vehicle_id)');
$this->addSql('CREATE TABLE animal (id CLOB NOT NULL, name CLOB NOT NULL, type VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX animal_idx ON animal (id)');
$this->addSql('CREATE TABLE vehicle (id CLOB NOT NULL, manufacturer CLOB NOT NULL, model CLOB NOT NULL, type VARCHAR(255) NOT NULL, seats_number INTEGER DEFAULT NULL, maximum_load INTEGER DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX vehicle_idx ON vehicle (id)');
}
public function down(Schema $schema) : void
{
$this->abortIf(
$this->connection->getDatabasePlatform()->getName() !== 'sqlite',
'Migration can only be executed safely on \'sqlite\'.'
);
$this->addSql('DROP TABLE person');
$this->addSql('DROP TABLE person_has_vehicle');
$this->addSql('DROP TABLE animal');
$this->addSql('DROP TABLE vehicle');
}
}