<?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 Version20180821201226 extends AbstractMigration
{
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('RENAME TABLE customers_interview_forms TO customer_interview_form');
$this->addSql('ALTER TABLE customer_interview_form ENGINE = InnoDB');
$this->addSql('ALTER TABLE customer_interview_form CHARACTER SET = utf8mb4');
$this->addSql('UPDATE customer_interview_form SET filed_last_3_years = 0 WHERE filed_last_3_years IS NULL');
$this->addSql('UPDATE customer_interview_form SET self_employed = 0 WHERE self_employed IS NULL');
$this->addSql('
ALTER TABLE customer_interview_form
ADD created_at DATETIME DEFAULT NULL,
ADD modified_at DATETIME DEFAULT NULL
');
$this->addSql('UPDATE customer_interview_form ci SET ci.created_at = (SELECT c.created_at FROM customer c WHERE c.id = ci.customers_id)');
$this->addSql('UPDATE customer_interview_form SET modified_at = created_at');
$this->addSql('
ALTER TABLE customer_interview_form
CHANGE customers_id customer_id INT DEFAULT NULL,
CHANGE irs_debt irs_debt VARCHAR(255) DEFAULT NULL,
CHANGE state_debt state_debt VARCHAR(255) DEFAULT NULL,
CHANGE tax_type tax_type VARCHAR(255) DEFAULT NULL,
CHANGE years_owed years_owed VARCHAR(255) DEFAULT NULL,
CHANGE latest_irs_action latest_irs_action VARCHAR(255) DEFAULT NULL,
CHANGE filed_last_3_years filed_last_3_years TINYINT(1) NOT NULL,
CHANGE self_employed self_employed TINYINT(1) NOT NULL,
CHANGE home_value home_value INT DEFAULT NULL,
CHANGE home_value_80 home_value_80 INT DEFAULT NULL,
CHANGE mortgage_balance mortgage_balance INT DEFAULT NULL,
CHANGE net_home_equity net_home_equity INT DEFAULT NULL,
CHANGE car_equity car_equity INT DEFAULT NULL,
CHANGE car_info car_info VARCHAR(255) DEFAULT NULL,
CHANGE other_equity other_equity INT DEFAULT NULL,
CHANGE total_equity total_equity INT DEFAULT NULL,
CHANGE checking_saving checking_saving INT DEFAULT NULL,
CHANGE age age INT DEFAULT NULL,
CHANGE spouses_age spouse_age INT DEFAULT NULL,
CHANGE available_credit available_credit INT DEFAULT NULL,
CHANGE credit_owed credit_owed INT DEFAULT NULL,
CHANGE dependents_at_home dependents_at_home INT DEFAULT NULL,
CHANGE monthly_income monthly_income INT DEFAULT NULL,
CHANGE nal_standard nal_standard INT DEFAULT NULL,
CHANGE spouses_income spouse_income INT DEFAULT NULL,
CHANGE rent_mortgage rent_mortgage INT DEFAULT NULL,
CHANGE business_income business_income INT DEFAULT NULL,
CHANGE utilities utilities INT DEFAULT NULL,
CHANGE other_income other_income INT DEFAULT NULL,
CHANGE car_payment_1 car_payment_1 INT DEFAULT NULL,
CHANGE car_payment_2 car_payment_2 INT DEFAULT NULL,
CHANGE taxable_income taxable_income INT DEFAULT NULL,
CHANGE vehicle_costs vehicle_costs INT DEFAULT NULL,
CHANGE health_insurance health_insurance INT DEFAULT NULL,
CHANGE govt_ssi govt_ssi INT DEFAULT NULL,
CHANGE other_health other_health INT DEFAULT NULL,
CHANGE non_taxes non_taxes INT DEFAULT NULL,
CHANGE taxes_15_30 taxes_15_30 INT DEFAULT NULL,
CHANGE court_ordered_pay court_ordered_pay INT DEFAULT NULL,
CHANGE child_disabled_care child_disabled_care INT DEFAULT NULL,
CHANGE life_insurance life_insurance INT DEFAULT NULL,
CHANGE total_income total_income INT DEFAULT NULL,
CHANGE secured_dept secured_dept INT DEFAULT NULL,
CHANGE other other INT DEFAULT NULL,
CHANGE total_expenses total_expenses INT DEFAULT NULL,
CHANGE allow_desp_income allow_desp_income INT DEFAULT NULL,
CHANGE income_factor income_factor INT DEFAULT NULL,
CHANGE total_equity_2 total_equity_2 INT DEFAULT NULL,
CHANGE possible_offer possible_offer INT DEFAULT NULL,
CHANGE created_at created_at DATETIME NOT NULL,
CHANGE modified_at modified_at DATETIME NOT NULL
');
$this->addSql('DROP INDEX idx_customers_id ON customer_interview_form');
$this->addSql('CREATE INDEX IDX_20001B639395C3F3 ON customer_interview_form (customer_id)');
$this->addSql('RENAME TABLE customers_interview_notes TO customer_interview_note');
$this->addSql('ALTER TABLE customer_interview_note ENGINE = InnoDB');
$this->addSql('ALTER TABLE customer_interview_note CHARACTER SET = utf8mb4');
$this->addSql('UPDATE customer_interview_note SET is_sales = 0 WHERE is_sales IS NULL');
$this->addSql('UPDATE customer_interview_note SET is_sent = 0 WHERE is_sent IS NULL');
$this->addSql('
ALTER TABLE customer_interview_note
CHANGE customers_id customer_id INT DEFAULT NULL,
CHANGE administrators_id user_id INT DEFAULT NULL,
CHANGE hours hours INT DEFAULT NULL,
CHANGE minutes minutes INT DEFAULT NULL,
CHANGE comments body LONGTEXT DEFAULT NULL,
CHANGE type type VARCHAR(255) DEFAULT NULL,
CHANGE method method_id INT DEFAULT NULL,
CHANGE other_type section VARCHAR(255) DEFAULT NULL,
CHANGE other_name tax_return_type VARCHAR(255) DEFAULT NULL,
CHANGE is_sales sales TINYINT(1) NOT NULL,
CHANGE is_sent sent TINYINT(1) NOT NULL,
CHANGE date_added created_at DATETIME NOT NULL,
CHANGE last_modified modified_at DATETIME NOT NULL
');
$this->addSql('UPDATE customer_interview_note SET type = NULL WHERE type = \'0\' OR type = \'\'');
$this->addSql('UPDATE customer_interview_note SET type = \'client_called_in\' WHERE type = \'1\'');
$this->addSql('UPDATE customer_interview_note SET type = \'called_client\' WHERE type = \'2\'');
$this->addSql('UPDATE customer_interview_note SET type = \'emailed_client\' WHERE type = \'3\'');
$this->addSql('UPDATE customer_interview_note SET type = \'texted_client\' WHERE type = \'8\'');
$this->addSql('UPDATE customer_interview_note SET type = \'sent_letter\' WHERE type = \'4\'');
$this->addSql('UPDATE customer_interview_note SET type = \'faxed_client\' WHERE type = \'5\'');
$this->addSql('UPDATE customer_interview_note SET type = \'met_with_client\' WHERE type = \'6\'');
$this->addSql('UPDATE customer_interview_note SET type = \'welcome_call\' WHERE type = \'7\'');
$this->addSql('UPDATE customer_interview_note SET type = \'live_chat\' WHERE type = \'9\'');
$this->addSql('UPDATE customer_interview_note SET section = NULL WHERE section = \'0\' OR section = \'\'');
$this->addSql('UPDATE customer_interview_note SET section = \'called\' WHERE section = \'1\'');
$this->addSql('UPDATE customer_interview_note SET section = \'faxed\' WHERE section = \'2\'');
$this->addSql('UPDATE customer_interview_note SET section = \'emailed\' WHERE section = \'3\'');
$this->addSql('UPDATE customer_interview_note SET section = \'sent_letter\' WHERE section = \'4\'');
$this->addSql('UPDATE customer_interview_note SET tax_return_type = NULL WHERE tax_return_type = \'\'');
$this->addSql('UPDATE customer_interview_note SET tax_return_type = \'federal\' WHERE tax_return_type = \'IRS\'');
$this->addSql('UPDATE customer_interview_note SET tax_return_type = \'state\' WHERE tax_return_type = \'State\'');
$this->addSql('ALTER TABLE customer_interview_note CHANGE type type ENUM(\'client_called_in\', \'called_client\', \'emailed_client\', \'texted_client\', \'sent_letter\', \'faxed_client\', \'met_with_client\', \'welcome_call\', \'live_chat\') DEFAULT NULL COMMENT \'(DC2Type:InterviewNoteType)\'');
$this->addSql('ALTER TABLE customer_interview_note CHANGE section section ENUM(\'called\', \'faxed\', \'emailed\', \'sent_letter\') DEFAULT NULL COMMENT \'(DC2Type:InterviewNoteSectionType)\'');
$this->addSql('ALTER TABLE customer_interview_note CHANGE tax_return_type tax_return_type ENUM(\'state\', \'federal\') DEFAULT NULL COMMENT \'(DC2Type:TaxReturnType)\'');
$this->addSql('DROP INDEX idx_customers_id ON customer_interview_note');
$this->addSql('DROP INDEX idx_administrators_id ON customer_interview_note');
$this->addSql('CREATE INDEX IDX_BD351C389395C3F3 ON customer_interview_note (customer_id)');
$this->addSql('CREATE INDEX IDX_BD351C38A76ED395 ON customer_interview_note (user_id)');
$this->addSql('CREATE INDEX IDX_BD351C3819883967 ON customer_interview_note (method_id)');
$this->addSql('DELETE FROM customer_interview_form WHERE customer_id NOT IN (SELECT id FROM customer)');
$this->addSql('DELETE FROM customer_interview_note WHERE customer_id NOT IN (SELECT id FROM customer)');
$this->addSql('UPDATE customer_interview_note SET user_id = NULL WHERE user_id NOT IN (SELECT id FROM user)');
$this->addSql('UPDATE customer_interview_note SET method_id = NULL WHERE method_id NOT IN (SELECT id FROM config_interview_note_method)');
$this->addSql('ALTER TABLE customer_interview_form ADD CONSTRAINT FK_20001B639395C3F3 FOREIGN KEY (customer_id) REFERENCES customer (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE customer_interview_note ADD CONSTRAINT FK_BD351C389395C3F3 FOREIGN KEY (customer_id) REFERENCES customer (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE customer_interview_note ADD CONSTRAINT FK_BD351C38A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE SET NULL');
$this->addSql('ALTER TABLE customer_interview_note ADD CONSTRAINT FK_BD351C3819883967 FOREIGN KEY (method_id) REFERENCES config_interview_note_method (id) ON DELETE SET NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE customer_interview_note DROP FOREIGN KEY FK_BD351C3819883967');
$this->addSql('ALTER TABLE customer_interview_note DROP FOREIGN KEY FK_BD351C38A76ED395');
$this->addSql('ALTER TABLE customer_interview_note DROP FOREIGN KEY FK_BD351C389395C3F3');
$this->addSql('ALTER TABLE customer_interview_form DROP FOREIGN KEY FK_20001B639395C3F3');
$this->addSql('RENAME TABLE customer_interview_form TO customers_interview_forms');
$this->addSql('ALTER TABLE customers_interview_forms ENGINE = InnoDB');
$this->addSql('ALTER TABLE customers_interview_forms CHARACTER SET = utf8mb4');
$this->addSql('
ALTER TABLE customers_interview_forms
DROP created_at,
DROP modified_at,
CHANGE customer_id customers_id INT NOT NULL,
CHANGE irs_debt irs_debt VARCHAR(64) DEFAULT NULL,
CHANGE state_debt state_debt VARCHAR(64) DEFAULT NULL,
CHANGE tax_type tax_type VARCHAR(64) DEFAULT NULL,
CHANGE years_owed years_owed VARCHAR(64) DEFAULT NULL,
CHANGE latest_irs_action latest_irs_action VARCHAR(64) DEFAULT NULL,
CHANGE filed_last_3_years filed_last_3_years TINYINT(1) DEFAULT NULL,
CHANGE self_employed self_employed TINYINT(1) DEFAULT NULL,
CHANGE home_value home_value INT DEFAULT NULL,
CHANGE home_value_80 home_value_80 INT DEFAULT NULL,
CHANGE mortgage_balance mortgage_balance INT DEFAULT NULL,
CHANGE net_home_equity net_home_equity INT DEFAULT NULL,
CHANGE car_equity car_equity INT DEFAULT NULL,
CHANGE car_info car_info VARCHAR(64) DEFAULT NULL,
CHANGE other_equity other_equity INT DEFAULT NULL,
CHANGE total_equity total_equity INT DEFAULT NULL,
CHANGE checking_saving checking_saving INT DEFAULT NULL,
CHANGE age age INT DEFAULT NULL,
CHANGE spouse_age spouses_age INT DEFAULT NULL,
CHANGE available_credit available_credit INT DEFAULT NULL,
CHANGE credit_owed credit_owed INT DEFAULT NULL,
CHANGE dependents_at_home dependents_at_home INT DEFAULT NULL,
CHANGE monthly_income monthly_income INT DEFAULT NULL,
CHANGE nal_standard nal_standard INT DEFAULT NULL,
CHANGE spouse_income spouses_income INT DEFAULT NULL,
CHANGE rent_mortgage rent_mortgage INT DEFAULT NULL,
CHANGE business_income business_income INT DEFAULT NULL,
CHANGE utilities utilities INT DEFAULT NULL,
CHANGE other_income other_income INT DEFAULT NULL,
CHANGE car_payment_1 car_payment_1 INT DEFAULT NULL,
CHANGE car_payment_2 car_payment_2 INT DEFAULT NULL,
CHANGE taxable_income taxable_income INT DEFAULT NULL,
CHANGE vehicle_costs vehicle_costs INT DEFAULT NULL,
CHANGE health_insurance health_insurance INT DEFAULT NULL,
CHANGE govt_ssi govt_ssi INT DEFAULT NULL,
CHANGE other_health other_health INT DEFAULT NULL,
CHANGE non_taxes non_taxes INT DEFAULT NULL,
CHANGE taxes_15_30 taxes_15_30 INT DEFAULT NULL,
CHANGE court_ordered_pay court_ordered_pay INT DEFAULT NULL,
CHANGE child_disabled_care child_disabled_care INT DEFAULT NULL,
CHANGE life_insurance life_insurance INT DEFAULT NULL,
CHANGE total_income total_income INT DEFAULT NULL,
CHANGE secured_dept secured_dept INT DEFAULT NULL,
CHANGE other other INT DEFAULT NULL,
CHANGE total_expenses total_expenses INT DEFAULT NULL,
CHANGE allow_desp_income allow_desp_income INT DEFAULT NULL,
CHANGE income_factor income_factor INT DEFAULT NULL,
CHANGE total_equity_2 total_equity_2 INT DEFAULT NULL,
CHANGE possible_offer possible_offer INT DEFAULT NULL
');
$this->addSql('DROP INDEX IDX_20001B639395C3F3 ON customers_interview_forms');
$this->addSql('CREATE INDEX idx_customers_id ON customers_interview_forms (customers_id)');
$this->addSql('RENAME TABLE customer_interview_note TO customers_interview_notes');
$this->addSql('ALTER TABLE customers_interview_notes ENGINE = InnoDB');
$this->addSql('ALTER TABLE customers_interview_notes CHARACTER SET = utf8mb4');
$this->addSql('
ALTER TABLE customers_interview_notes
CHANGE customer_id customers_id INT NOT NULL,
CHANGE user_id administrators_id INT NOT NULL,
CHANGE hours hours INT DEFAULT \'0\',
CHANGE minutes minutes INT DEFAULT \'0\',
CHANGE body comments TEXT DEFAULT NULL,
CHANGE type type VARCHAR(255) DEFAULT NULL,
CHANGE method_id method TINYINT(1) DEFAULT \'0\',
CHANGE section other_type VARCHAR(255) DEFAULT NULL,
CHANGE tax_return_type other_name VARCHAR(255) DEFAULT NULL,
CHANGE sales is_sales TINYINT(1) DEFAULT \'0\',
CHANGE sent is_sent TINYINT(1) DEFAULT \'0\',
CHANGE created_at date_added DATETIME DEFAULT NULL,
CHANGE modified_at last_modified DATETIME DEFAULT NULL
');
$this->addSql('UPDATE customers_interview_notes SET type = \'1\' WHERE type = \'client_called_in\'');
$this->addSql('UPDATE customers_interview_notes SET type = \'2\' WHERE type = \'called_client\'');
$this->addSql('UPDATE customers_interview_notes SET type = \'3\' WHERE type = \'emailed_client\'');
$this->addSql('UPDATE customers_interview_notes SET type = \'8\' WHERE type = \'texted_client\'');
$this->addSql('UPDATE customers_interview_notes SET type = \'4\' WHERE type = \'sent_letter\'');
$this->addSql('UPDATE customers_interview_notes SET type = \'5\' WHERE type = \'faxed_client\'');
$this->addSql('UPDATE customers_interview_notes SET type = \'6\' WHERE type = \'met_with_client\'');
$this->addSql('UPDATE customers_interview_notes SET type = \'7\' WHERE type = \'welcome_call\'');
$this->addSql('UPDATE customers_interview_notes SET type = \'9\' WHERE type = \'live_chat\'');
$this->addSql('UPDATE customers_interview_notes SET other_type = \'1\' WHERE other_type = \'called\'');
$this->addSql('UPDATE customers_interview_notes SET other_type = \'2\' WHERE other_type = \'faxed\'');
$this->addSql('UPDATE customers_interview_notes SET other_type = \'3\' WHERE other_type = \'emailed\'');
$this->addSql('UPDATE customers_interview_notes SET other_type = \'4\' WHERE other_type = \'sent_letter\'');
$this->addSql('UPDATE customers_interview_notes SET other_name = \'IRS\' WHERE other_name = \'federal\'');
$this->addSql('UPDATE customers_interview_notes SET other_name = \'State\' WHERE other_name = \'state\'');
$this->addSql('ALTER TABLE customers_interview_notes CHANGE type type TINYINT(1) DEFAULT \'0\'');
$this->addSql('ALTER TABLE customers_interview_notes CHANGE other_type other_type TINYINT(1) DEFAULT \'0\'');
$this->addSql('ALTER TABLE customers_interview_notes CHANGE other_name other_name ENUM(\'IRS\', \'State\') DEFAULT NULL');
$this->addSql('DROP INDEX IDX_BD351C389395C3F3 ON customers_interview_notes');
$this->addSql('DROP INDEX IDX_BD351C38A76ED395 ON customers_interview_notes');
$this->addSql('DROP INDEX IDX_BD351C3819883967 ON customers_interview_notes');
$this->addSql('CREATE INDEX idx_administrators_id ON customers_interview_notes (administrators_id)');
$this->addSql('CREATE INDEX idx_customers_id ON customers_interview_notes (customers_id)');
}
}