<?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 Version20230804070858 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 balance_transactions (id INT AUTO_INCREMENT NOT NULL, order_by_id VARCHAR(22) DEFAULT NULL, credit_history_id VARCHAR(22) DEFAULT NULL, mission_id VARCHAR(22) DEFAULT NULL, name VARCHAR(255) NOT NULL, create_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', type VARCHAR(255) NOT NULL, amount DOUBLE PRECISION NOT NULL, current_balance DOUBLE PRECISION NOT NULL, individual_billing DOUBLE PRECISION DEFAULT NULL, INDEX IDX_A479A1FA297954F9 (order_by_id), INDEX IDX_A479A1FAED7D3FEC (credit_history_id), INDEX IDX_A479A1FABE6CAE90 (mission_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE balance_transactions ADD CONSTRAINT FK_A479A1FA297954F9 FOREIGN KEY (order_by_id) REFERENCES users (id)');
$this->addSql('ALTER TABLE balance_transactions ADD CONSTRAINT FK_A479A1FAED7D3FEC FOREIGN KEY (credit_history_id) REFERENCES credit_history (id)');
$this->addSql('ALTER TABLE balance_transactions ADD CONSTRAINT FK_A479A1FABE6CAE90 FOREIGN KEY (mission_id) REFERENCES missions (id)');
$this->addSql('DROP TABLE notifications');
$this->addSql('ALTER TABLE campaigns ADD credit_history_id VARCHAR(22) DEFAULT NULL, CHANGE payment_method payment_method VARCHAR(255) DEFAULT NULL, CHANGE activated_at activated_at DATETIME DEFAULT NULL COMMENT \'(DC2Type:datetime_immutable)\', CHANGE client_status client_status VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE campaigns ADD CONSTRAINT FK_E3737470ED7D3FEC FOREIGN KEY (credit_history_id) REFERENCES credit_history (id)');
$this->addSql('CREATE INDEX IDX_E3737470ED7D3FEC ON campaigns (credit_history_id)');
$this->addSql('ALTER TABLE companies CHANGE current_balance current_balance NUMERIC(10, 2) DEFAULT NULL');
$this->addSql('ALTER TABLE credit_history ADD automatic_renewal TINYINT(1) DEFAULT NULL, ADD end_date_contract DATETIME DEFAULT NULL, ADD order_price DOUBLE PRECISION NOT NULL, ADD current_balance DOUBLE PRECISION NOT NULL, ADD fin_du_mois INT DEFAULT NULL, ADD availability_duration INT DEFAULT NULL, ADD balance_reason_updated VARCHAR(255) DEFAULT NULL, ADD deleted TINYINT(1) DEFAULT NULL, ADD total_consumption DOUBLE PRECISION NOT NULL');
$this->addSql('ALTER TABLE messages ADD mission_id VARCHAR(22) DEFAULT NULL, ADD user_list_who_read LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:array)\'');
$this->addSql('ALTER TABLE messages ADD CONSTRAINT FK_DB021E96BE6CAE90 FOREIGN KEY (mission_id) REFERENCES missions (id)');
$this->addSql('CREATE INDEX IDX_DB021E96BE6CAE90 ON messages (mission_id)');
$this->addSql('ALTER TABLE mission_participants CHANGE refused refused TINYINT(1) NOT NULL, CHANGE state_add state_add INT DEFAULT NULL');
$this->addSql('ALTER TABLE missions ADD last_state VARCHAR(255) DEFAULT NULL, ADD can_invoiced TINYINT(1) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE notifications (id INT AUTO_INCREMENT NOT NULL, send_to VARCHAR(22) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, campaign_id VARCHAR(22) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, send_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', type SMALLINT NOT NULL, INDEX IDX_6000B0D37B2D8BEF (send_to), INDEX IDX_6000B0D3F639F774 (campaign_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
$this->addSql('ALTER TABLE notifications ADD CONSTRAINT FK_6000B0D3F639F774 FOREIGN KEY (campaign_id) REFERENCES campaigns (id)');
$this->addSql('ALTER TABLE notifications ADD CONSTRAINT FK_6000B0D37B2D8BEF FOREIGN KEY (send_to) REFERENCES users (id)');
$this->addSql('DROP TABLE balance_transactions');
$this->addSql('ALTER TABLE campaigns DROP FOREIGN KEY FK_E3737470ED7D3FEC');
$this->addSql('DROP INDEX IDX_E3737470ED7D3FEC ON campaigns');
$this->addSql('ALTER TABLE campaigns DROP credit_history_id, CHANGE payment_method payment_method TEXT CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, CHANGE activated_at activated_at DATETIME DEFAULT NULL COMMENT \' (DC2Type:datetime_immutable)\', CHANGE client_status client_status VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`');
$this->addSql('ALTER TABLE companies CHANGE current_balance current_balance INT DEFAULT NULL');
$this->addSql('ALTER TABLE credit_history DROP automatic_renewal, DROP end_date_contract, DROP order_price, DROP current_balance, DROP fin_du_mois, DROP availability_duration, DROP balance_reason_updated, DROP deleted, DROP total_consumption');
$this->addSql('ALTER TABLE messages DROP FOREIGN KEY FK_DB021E96BE6CAE90');
$this->addSql('DROP INDEX IDX_DB021E96BE6CAE90 ON messages');
$this->addSql('ALTER TABLE messages DROP mission_id, DROP user_list_who_read');
$this->addSql('ALTER TABLE mission_participants CHANGE refused refused TINYINT(1) DEFAULT \'0\' NOT NULL, CHANGE state_add state_add INT DEFAULT NULL COMMENT \'when admin insert : 0
when prestaitre insert : 1
no insert : null\'');
$this->addSql('ALTER TABLE missions DROP last_state, DROP can_invoiced');
}
}