<?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 Version20220620064418 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->addSql('CREATE TABLE User (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(180) NOT NULL, company_name VARCHAR(180) NOT NULL, roles JSON NOT NULL, name VARCHAR(180) NOT NULL, surname VARCHAR(180) NOT NULL, phone VARCHAR(20) NOT NULL, password VARCHAR(255) NOT NULL, is_managent_active TINYINT(1) DEFAULT \'0\' NOT NULL, is_verified TINYINT(1) DEFAULT NULL, subdomain VARCHAR(50) DEFAULT NULL, UNIQUE INDEX email (email), UNIQUE INDEX subdomain (subdomain), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE api_key_map (id INT AUTO_INCREMENT NOT NULL, api_key_id INT DEFAULT NULL, api_id INT DEFAULT NULL, INDEX FK_api_key_map_apis (api_id), INDEX FK_api_key_map_api_keys (api_key_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE api_keys (id INT AUTO_INCREMENT NOT NULL, customer_id INT DEFAULT NULL, api_key VARCHAR(250) DEFAULT NULL, name VARCHAR(250) DEFAULT NULL, INDEX FK_api_keys_user (customer_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE apis (id INT AUTO_INCREMENT NOT NULL, elasticsearch_domain_id INT DEFAULT NULL, customer_id INT DEFAULT NULL, name VARCHAR(250) DEFAULT NULL, path VARCHAR(250) DEFAULT NULL, INDEX fk_elasticsearch_domain (elasticsearch_domain_id), INDEX fk_customer (customer_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE elasticsearch_domain (id INT AUTO_INCREMENT NOT NULL, customer_id INT DEFAULT NULL, es_host VARCHAR(250) DEFAULT NULL, es_password VARCHAR(250) DEFAULT NULL, es_user VARCHAR(250) DEFAULT NULL, es_cloud_id INT DEFAULT NULL, es_key_id INT DEFAULT NULL, es_api_key VARCHAR(250) DEFAULT NULL, INDEX fk_customer_id (customer_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE endpoind_fields (id INT AUTO_INCREMENT NOT NULL, static_field_type_id INT DEFAULT NULL, endpoind_id INT DEFAULT NULL, object_model_id INT DEFAULT NULL, name VARCHAR(50) DEFAULT NULL, example_value VARCHAR(50) DEFAULT NULL, is_sortable TINYINT(1) DEFAULT NULL, is_searchable TINYINT(1) DEFAULT NULL, is_aggregatable TINYINT(1) DEFAULT NULL, INDEX fk__static_fields (static_field_type_id), INDEX fk_endpoind (endpoind_id), INDEX fk_object_model (object_model_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE endpoind_object_fields (id INT AUTO_INCREMENT NOT NULL, endpoind_field_id INT DEFAULT NULL, model_field_id INT DEFAULT NULL, INDEX fk_endpoind_field (endpoind_field_id), INDEX fk_model_field (model_field_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE endpoinds (id INT AUTO_INCREMENT NOT NULL, request_type_id INT DEFAULT NULL, api_id INT DEFAULT NULL, path VARCHAR(50) DEFAULT NULL, description LONGTEXT DEFAULT NULL, INDEX fk_request_type (request_type_id), INDEX fk_api (api_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE model_fields (id INT AUTO_INCREMENT NOT NULL, model_id INT DEFAULT NULL, static_field_id INT DEFAULT NULL, object_model_id INT DEFAULT NULL, name VARCHAR(50) DEFAULT NULL, example_value VARCHAR(250) DEFAULT NULL, is_sortable TINYINT(1) DEFAULT NULL, is_searchable TINYINT(1) DEFAULT NULL, is_aggregatable TINYINT(1) DEFAULT NULL, primary_key TINYINT(1) DEFAULT NULL, INDEX fk_elasaticsearch_model (model_id), INDEX fk_static_field (static_field_id), INDEX fk_object_model_id (object_model_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE models (id INT AUTO_INCREMENT NOT NULL, customer_id INT DEFAULT NULL, name VARCHAR(50) DEFAULT NULL, INDEX FK_models_user (customer_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE request_type (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(50) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE reset_password_request (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, selector VARCHAR(20) NOT NULL, hashed_token VARCHAR(100) NOT NULL, requested_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', expires_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_7CE748AA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE static_fields (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(50) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE messenger_messages (id BIGINT AUTO_INCREMENT NOT NULL, body LONGTEXT NOT NULL, headers LONGTEXT NOT NULL, queue_name VARCHAR(190) NOT NULL, created_at DATETIME NOT NULL, available_at DATETIME NOT NULL, delivered_at DATETIME DEFAULT NULL, INDEX IDX_75EA56E0FB7336F0 (queue_name), INDEX IDX_75EA56E0E3BD61CE (available_at), INDEX IDX_75EA56E016BA31DB (delivered_at), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE api_key_map ADD CONSTRAINT FK_AA9AC30C8BE312B3 FOREIGN KEY (api_key_id) REFERENCES api_keys (id)');
$this->addSql('ALTER TABLE api_key_map ADD CONSTRAINT FK_AA9AC30C54963938 FOREIGN KEY (api_id) REFERENCES apis (id)');
$this->addSql('ALTER TABLE api_keys ADD CONSTRAINT FK_9579321F9395C3F3 FOREIGN KEY (customer_id) REFERENCES User (id)');
$this->addSql('ALTER TABLE apis ADD CONSTRAINT FK_8B1CD7423DE5A611 FOREIGN KEY (elasticsearch_domain_id) REFERENCES elasticsearch_domain (id)');
$this->addSql('ALTER TABLE apis ADD CONSTRAINT FK_8B1CD7429395C3F3 FOREIGN KEY (customer_id) REFERENCES User (id)');
$this->addSql('ALTER TABLE elasticsearch_domain ADD CONSTRAINT FK_131EAE49395C3F3 FOREIGN KEY (customer_id) REFERENCES User (id)');
$this->addSql('ALTER TABLE endpoind_fields ADD CONSTRAINT FK_3F48715C3C78ABF FOREIGN KEY (static_field_type_id) REFERENCES static_fields (id)');
$this->addSql('ALTER TABLE endpoind_fields ADD CONSTRAINT FK_3F48715C71B629A9 FOREIGN KEY (endpoind_id) REFERENCES endpoinds (id)');
$this->addSql('ALTER TABLE endpoind_fields ADD CONSTRAINT FK_3F48715CAFA35A8F FOREIGN KEY (object_model_id) REFERENCES models (id)');
$this->addSql('ALTER TABLE endpoind_object_fields ADD CONSTRAINT FK_9458B7E9BF62B46E FOREIGN KEY (endpoind_field_id) REFERENCES endpoind_fields (id)');
$this->addSql('ALTER TABLE endpoind_object_fields ADD CONSTRAINT FK_9458B7E98EED5653 FOREIGN KEY (model_field_id) REFERENCES model_fields (id)');
$this->addSql('ALTER TABLE endpoinds ADD CONSTRAINT FK_96DF37E1EF68FEC4 FOREIGN KEY (request_type_id) REFERENCES request_type (id)');
$this->addSql('ALTER TABLE endpoinds ADD CONSTRAINT FK_96DF37E154963938 FOREIGN KEY (api_id) REFERENCES apis (id)');
$this->addSql('ALTER TABLE model_fields ADD CONSTRAINT FK_5D02C7177975B7E7 FOREIGN KEY (model_id) REFERENCES models (id)');
$this->addSql('ALTER TABLE model_fields ADD CONSTRAINT FK_5D02C7175AAF778C FOREIGN KEY (static_field_id) REFERENCES static_fields (id)');
$this->addSql('ALTER TABLE model_fields ADD CONSTRAINT FK_5D02C717AFA35A8F FOREIGN KEY (object_model_id) REFERENCES models (id)');
$this->addSql('ALTER TABLE models ADD CONSTRAINT FK_E4D630099395C3F3 FOREIGN KEY (customer_id) REFERENCES User (id)');
$this->addSql('ALTER TABLE reset_password_request ADD CONSTRAINT FK_7CE748AA76ED395 FOREIGN KEY (user_id) REFERENCES User (id)');
$staticFields = array('integer', 'boolean', 'string', 'nested', 'object');
foreach($staticFields as $staticField) {
$this->addSql('INSERT INTO static_fields (name) VALUES (?)', array($staticField));
}
$requestTypes = array('POST', 'GET', 'PUT', 'PATCH', 'DELETE');
foreach($requestTypes as $requestType) {
$this->addSql('INSERT INTO request_type (name) VALUES (?)', array($requestType));
}
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE api_keys DROP FOREIGN KEY FK_9579321F9395C3F3');
$this->addSql('ALTER TABLE apis DROP FOREIGN KEY FK_8B1CD7429395C3F3');
$this->addSql('ALTER TABLE elasticsearch_domain DROP FOREIGN KEY FK_131EAE49395C3F3');
$this->addSql('ALTER TABLE models DROP FOREIGN KEY FK_E4D630099395C3F3');
$this->addSql('ALTER TABLE reset_password_request DROP FOREIGN KEY FK_7CE748AA76ED395');
$this->addSql('ALTER TABLE api_key_map DROP FOREIGN KEY FK_AA9AC30C8BE312B3');
$this->addSql('ALTER TABLE api_key_map DROP FOREIGN KEY FK_AA9AC30C54963938');
$this->addSql('ALTER TABLE endpoinds DROP FOREIGN KEY FK_96DF37E154963938');
$this->addSql('ALTER TABLE apis DROP FOREIGN KEY FK_8B1CD7423DE5A611');
$this->addSql('ALTER TABLE endpoind_object_fields DROP FOREIGN KEY FK_9458B7E9BF62B46E');
$this->addSql('ALTER TABLE endpoind_fields DROP FOREIGN KEY FK_3F48715C71B629A9');
$this->addSql('ALTER TABLE endpoind_object_fields DROP FOREIGN KEY FK_9458B7E98EED5653');
$this->addSql('ALTER TABLE endpoind_fields DROP FOREIGN KEY FK_3F48715CAFA35A8F');
$this->addSql('ALTER TABLE model_fields DROP FOREIGN KEY FK_5D02C7177975B7E7');
$this->addSql('ALTER TABLE model_fields DROP FOREIGN KEY FK_5D02C717AFA35A8F');
$this->addSql('ALTER TABLE endpoinds DROP FOREIGN KEY FK_96DF37E1EF68FEC4');
$this->addSql('ALTER TABLE endpoind_fields DROP FOREIGN KEY FK_3F48715C3C78ABF');
$this->addSql('ALTER TABLE model_fields DROP FOREIGN KEY FK_5D02C7175AAF778C');
$this->addSql('DROP TABLE User');
$this->addSql('DROP TABLE api_key_map');
$this->addSql('DROP TABLE api_keys');
$this->addSql('DROP TABLE apis');
$this->addSql('DROP TABLE elasticsearch_domain');
$this->addSql('DROP TABLE endpoind_fields');
$this->addSql('DROP TABLE endpoind_object_fields');
$this->addSql('DROP TABLE endpoinds');
$this->addSql('DROP TABLE model_fields');
$this->addSql('DROP TABLE models');
$this->addSql('DROP TABLE request_type');
$this->addSql('DROP TABLE reset_password_request');
$this->addSql('DROP TABLE static_fields');
$this->addSql('DROP TABLE messenger_messages');
}
}