<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200311135917 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE SEQUENCE devices_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE data_samples_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE project_information_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE measurements_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE probes_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE recipes_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE customers_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE channels_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE cached_responses_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE user_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE devices (id INT NOT NULL, customer_id INT DEFAULT NULL, serial_number VARCHAR(255) NOT NULL, created_at TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL, updated_at TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_11074E9A9395C3F3 ON devices (customer_id)');
$this->addSql('COMMENT ON COLUMN devices.serial_number IS \'Serial number.\'');
$this->addSql('COMMENT ON COLUMN devices.created_at IS \'Date of the entity creation. Should be fixed.\'');
$this->addSql('COMMENT ON COLUMN devices.updated_at IS \'Date of the last change in entity. Shouldn’t be set to other dates.\'');
$this->addSql('CREATE TABLE data_samples (id INT NOT NULL, device_id INT NOT NULL, recipe_id INT NOT NULL, started_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, measured_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, measuring_interval DOUBLE PRECISION NOT NULL, battery_level TEXT DEFAULT NULL, status INT NOT NULL, created_at TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL, updated_at TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_7D99018694A4C7D4 ON data_samples (device_id)');
$this->addSql('CREATE INDEX IDX_7D99018659D8A214 ON data_samples (recipe_id)');
$this->addSql('COMMENT ON COLUMN data_samples.started_at IS \'Started at.\'');
$this->addSql('COMMENT ON COLUMN data_samples.measured_at IS \'Measured at.\'');
$this->addSql('COMMENT ON COLUMN data_samples.measuring_interval IS \'Measuring interval.\'');
$this->addSql('COMMENT ON COLUMN data_samples.battery_level IS \'Battery level.\'');
$this->addSql('COMMENT ON COLUMN data_samples.status IS \'Allowed values: START, RUN, STOP.\'');
$this->addSql('COMMENT ON COLUMN data_samples.created_at IS \'Date of the entity creation. Should be fixed.\'');
$this->addSql('COMMENT ON COLUMN data_samples.updated_at IS \'Date of the last change in entity. Shouldn’t be set to other dates.\'');
$this->addSql('CREATE TABLE project_information (id INT NOT NULL, measurement_id INT NOT NULL, heading TEXT DEFAULT NULL, content TEXT DEFAULT NULL, created_at TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL, updated_at TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_E1B6EF78924EA134 ON project_information (measurement_id)');
$this->addSql('COMMENT ON COLUMN project_information.heading IS \'Information key.\'');
$this->addSql('COMMENT ON COLUMN project_information.content IS \'Information value.\'');
$this->addSql('COMMENT ON COLUMN project_information.created_at IS \'Date of the entity creation. Should be fixed.\'');
$this->addSql('COMMENT ON COLUMN project_information.updated_at IS \'Date of the last change in entity. Shouldn’t be set to other dates.\'');
$this->addSql('CREATE TABLE measurements (id INT NOT NULL, device_id INT NOT NULL, customer_id INT DEFAULT NULL, created_at TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL, updated_at TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_71920F2194A4C7D4 ON measurements (device_id)');
$this->addSql('CREATE INDEX IDX_71920F219395C3F3 ON measurements (customer_id)');
$this->addSql('COMMENT ON COLUMN measurements.created_at IS \'Date of the entity creation. Should be fixed.\'');
$this->addSql('COMMENT ON COLUMN measurements.updated_at IS \'Date of the last change in entity. Shouldn’t be set to other dates.\'');
$this->addSql('CREATE TABLE probes (id INT NOT NULL, data_sample_id INT NOT NULL, channel_id INT NOT NULL, temperature INT NOT NULL, time TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_C06258B294B0AA16 ON probes (data_sample_id)');
$this->addSql('CREATE INDEX IDX_C06258B272F5A1AA ON probes (channel_id)');
$this->addSql('COMMENT ON COLUMN probes.temperature IS \'Temperature.\'');
$this->addSql('CREATE TABLE recipes (id INT NOT NULL, name TEXT NOT NULL, created_at TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL, updated_at TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('COMMENT ON COLUMN recipes.name IS \'Recipe name.\'');
$this->addSql('COMMENT ON COLUMN recipes.created_at IS \'Date of the entity creation. Should be fixed.\'');
$this->addSql('COMMENT ON COLUMN recipes.updated_at IS \'Date of the last change in entity. Shouldn’t be set to other dates.\'');
$this->addSql('CREATE TABLE customers (id INT NOT NULL, created_at TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL, updated_at TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('COMMENT ON COLUMN customers.created_at IS \'Date of the entity creation. Should be fixed.\'');
$this->addSql('COMMENT ON COLUMN customers.updated_at IS \'Date of the last change in entity. Shouldn’t be set to other dates.\'');
$this->addSql('CREATE TABLE channels (id INT NOT NULL, recipe_id INT DEFAULT NULL, measurement_id INT NOT NULL, channel_number INT NOT NULL, created_at TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL, updated_at TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_F314E2B659D8A214 ON channels (recipe_id)');
$this->addSql('CREATE INDEX IDX_F314E2B6924EA134 ON channels (measurement_id)');
$this->addSql('COMMENT ON COLUMN channels.channel_number IS \'Channel number.\'');
$this->addSql('COMMENT ON COLUMN channels.created_at IS \'Date of the entity creation. Should be fixed.\'');
$this->addSql('COMMENT ON COLUMN channels.updated_at IS \'Date of the last change in entity. Shouldn’t be set to other dates.\'');
$this->addSql('CREATE TABLE cached_responses (id INT NOT NULL, request_id TEXT NOT NULL, response_code INT NOT NULL, response TEXT NOT NULL, route VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE TABLE "user" (id INT NOT NULL, customer_id INT DEFAULT NULL, email VARCHAR(180) NOT NULL, roles JSON NOT NULL, password VARCHAR(255) NOT NULL, created_at TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL, updated_at TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D649E7927C74 ON "user" (email)');
$this->addSql('CREATE INDEX IDX_8D93D6499395C3F3 ON "user" (customer_id)');
$this->addSql('COMMENT ON COLUMN "user".created_at IS \'Date of the entity creation. Should be fixed.\'');
$this->addSql('COMMENT ON COLUMN "user".updated_at IS \'Date of the last change in entity. Shouldn’t be set to other dates.\'');
$this->addSql('ALTER TABLE devices ADD CONSTRAINT FK_11074E9A9395C3F3 FOREIGN KEY (customer_id) REFERENCES customers (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE data_samples ADD CONSTRAINT FK_7D99018694A4C7D4 FOREIGN KEY (device_id) REFERENCES devices (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE data_samples ADD CONSTRAINT FK_7D99018659D8A214 FOREIGN KEY (recipe_id) REFERENCES recipes (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE project_information ADD CONSTRAINT FK_E1B6EF78924EA134 FOREIGN KEY (measurement_id) REFERENCES measurements (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE measurements ADD CONSTRAINT FK_71920F2194A4C7D4 FOREIGN KEY (device_id) REFERENCES devices (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE measurements ADD CONSTRAINT FK_71920F219395C3F3 FOREIGN KEY (customer_id) REFERENCES customers (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE probes ADD CONSTRAINT FK_C06258B294B0AA16 FOREIGN KEY (data_sample_id) REFERENCES data_samples (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE probes ADD CONSTRAINT FK_C06258B272F5A1AA FOREIGN KEY (channel_id) REFERENCES channels (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE channels ADD CONSTRAINT FK_F314E2B659D8A214 FOREIGN KEY (recipe_id) REFERENCES recipes (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE channels ADD CONSTRAINT FK_F314E2B6924EA134 FOREIGN KEY (measurement_id) REFERENCES measurements (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE "user" ADD CONSTRAINT FK_8D93D6499395C3F3 FOREIGN KEY (customer_id) REFERENCES customers (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE data_samples DROP CONSTRAINT FK_7D99018694A4C7D4');
$this->addSql('ALTER TABLE measurements DROP CONSTRAINT FK_71920F2194A4C7D4');
$this->addSql('ALTER TABLE probes DROP CONSTRAINT FK_C06258B294B0AA16');
$this->addSql('ALTER TABLE project_information DROP CONSTRAINT FK_E1B6EF78924EA134');
$this->addSql('ALTER TABLE channels DROP CONSTRAINT FK_F314E2B6924EA134');
$this->addSql('ALTER TABLE data_samples DROP CONSTRAINT FK_7D99018659D8A214');
$this->addSql('ALTER TABLE channels DROP CONSTRAINT FK_F314E2B659D8A214');
$this->addSql('ALTER TABLE devices DROP CONSTRAINT FK_11074E9A9395C3F3');
$this->addSql('ALTER TABLE measurements DROP CONSTRAINT FK_71920F219395C3F3');
$this->addSql('ALTER TABLE "user" DROP CONSTRAINT FK_8D93D6499395C3F3');
$this->addSql('ALTER TABLE probes DROP CONSTRAINT FK_C06258B272F5A1AA');
$this->addSql('DROP SEQUENCE devices_id_seq CASCADE');
$this->addSql('DROP SEQUENCE data_samples_id_seq CASCADE');
$this->addSql('DROP SEQUENCE project_information_id_seq CASCADE');
$this->addSql('DROP SEQUENCE measurements_id_seq CASCADE');
$this->addSql('DROP SEQUENCE probes_id_seq CASCADE');
$this->addSql('DROP SEQUENCE recipes_id_seq CASCADE');
$this->addSql('DROP SEQUENCE customers_id_seq CASCADE');
$this->addSql('DROP SEQUENCE channels_id_seq CASCADE');
$this->addSql('DROP SEQUENCE cached_responses_id_seq CASCADE');
$this->addSql('DROP SEQUENCE user_id_seq CASCADE');
$this->addSql('DROP TABLE devices');
$this->addSql('DROP TABLE data_samples');
$this->addSql('DROP TABLE project_information');
$this->addSql('DROP TABLE measurements');
$this->addSql('DROP TABLE probes');
$this->addSql('DROP TABLE recipes');
$this->addSql('DROP TABLE customers');
$this->addSql('DROP TABLE channels');
$this->addSql('DROP TABLE cached_responses');
$this->addSql('DROP TABLE "user"');
}
}