<?php

declare(strict_types=1);

/*
 * Copyright Humbly Arrogant Software Limited 2023-2025.
 *
 * Use of this software is governed by the Fair Core License, Version 1.0, ALv2 Future License included in the LICENSE.md file and at https://github.com/BillaBear/billabear/blob/main/LICENSE.
 */

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
 * Auto-generated Migration: Please modify to your needs!
 */
final class Version20250126161959 extends AbstractMigration
{
    public function getDescription(): string
    {
        return '2025.01.01 migration';
    }

    public function up(Schema $schema): void
    {
        $this->addSql('CREATE TABLE event (id UUID NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, customer_id UUID DEFAULT NULL, subscription_id UUID DEFAULT NULL, metric_id UUID DEFAULT NULL, event_id VARCHAR(255) NOT NULL, value DOUBLE PRECISION NOT NULL, properties JSON NOT NULL, PRIMARY KEY(id, created_at))');
        $this->addSql('CREATE INDEX IDX_3BAE0AA79395C3F3 ON event (customer_id)');
        $this->addSql('CREATE INDEX IDX_3BAE0AA79A1887DC ON event (subscription_id)');
        $this->addSql('CREATE INDEX IDX_3BAE0AA7A952D583 ON event (metric_id)');
        $this->addSql('COMMENT ON COLUMN event.id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN event.customer_id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN event.subscription_id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN event.metric_id IS \'(DC2Type:uuid)\'');
        $this->addSql('CREATE TABLE invoice_delivery (id UUID NOT NULL, invoice_id UUID DEFAULT NULL, invoice_delivery_settings_id UUID DEFAULT NULL, customer_id UUID DEFAULT NULL, status VARCHAR(255) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE INDEX IDX_28A9B6482989F1FD ON invoice_delivery (invoice_id)');
        $this->addSql('CREATE INDEX IDX_28A9B648EA1C5E18 ON invoice_delivery (invoice_delivery_settings_id)');
        $this->addSql('CREATE INDEX IDX_28A9B6489395C3F3 ON invoice_delivery (customer_id)');
        $this->addSql('COMMENT ON COLUMN invoice_delivery.id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN invoice_delivery.invoice_id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN invoice_delivery.invoice_delivery_settings_id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN invoice_delivery.customer_id IS \'(DC2Type:uuid)\'');
        $this->addSql('CREATE TABLE invoice_delivery_settings (id UUID NOT NULL, customer_id UUID DEFAULT NULL, enabled VARCHAR(255) NOT NULL, invoice_format VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, webhook_method VARCHAR(255) DEFAULT NULL, webhook_url VARCHAR(255) DEFAULT NULL, sftp_host VARCHAR(255) DEFAULT NULL, sftp_user VARCHAR(255) DEFAULT NULL, sftp_password VARCHAR(255) DEFAULT NULL, sftp_dir VARCHAR(255) DEFAULT NULL, sftp_port INT DEFAULT NULL, email VARCHAR(255) DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE INDEX IDX_879A8A7C9395C3F3 ON invoice_delivery_settings (customer_id)');
        $this->addSql('COMMENT ON COLUMN invoice_delivery_settings.id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN invoice_delivery_settings.customer_id IS \'(DC2Type:uuid)\'');
        $this->addSql('CREATE TABLE invoice_metric_counter (id UUID NOT NULL, metric_id UUID DEFAULT NULL, invoice_id UUID DEFAULT NULL, metric_counter_id UUID DEFAULT NULL, value DOUBLE PRECISION NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE INDEX IDX_94B89AA952D583 ON invoice_metric_counter (metric_id)');
        $this->addSql('CREATE INDEX IDX_94B89A2989F1FD ON invoice_metric_counter (invoice_id)');
        $this->addSql('CREATE INDEX IDX_94B89A4E05402E ON invoice_metric_counter (metric_counter_id)');
        $this->addSql('COMMENT ON COLUMN invoice_metric_counter.id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN invoice_metric_counter.metric_id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN invoice_metric_counter.invoice_id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN invoice_metric_counter.metric_counter_id IS \'(DC2Type:uuid)\'');
        $this->addSql('CREATE TABLE metric (id UUID NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, aggregation_method VARCHAR(255) NOT NULL, aggregation_property VARCHAR(255) DEFAULT NULL, event_ingestion VARCHAR(255) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE UNIQUE INDEX UNIQ_87D62EE377153098 ON metric (code)');
        $this->addSql('COMMENT ON COLUMN metric.id IS \'(DC2Type:uuid)\'');
        $this->addSql('CREATE TABLE metric_counter (id UUID NOT NULL, metric_id UUID DEFAULT NULL, customer_id UUID DEFAULT NULL, value DOUBLE PRECISION NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE INDEX IDX_E01686F6A952D583 ON metric_counter (metric_id)');
        $this->addSql('CREATE INDEX IDX_E01686F69395C3F3 ON metric_counter (customer_id)');
        $this->addSql('COMMENT ON COLUMN metric_counter.id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN metric_counter.metric_id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN metric_counter.customer_id IS \'(DC2Type:uuid)\'');
        $this->addSql('CREATE TABLE metric_filter (id UUID NOT NULL, metric_id UUID DEFAULT NULL, name VARCHAR(255) NOT NULL, value VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE INDEX IDX_FF226429A952D583 ON metric_filter (metric_id)');
        $this->addSql('COMMENT ON COLUMN metric_filter.id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN metric_filter.metric_id IS \'(DC2Type:uuid)\'');
        $this->addSql('CREATE TABLE price_tier_component (id UUID NOT NULL, price_id UUID DEFAULT NULL, first_unit INT NOT NULL, last_unit INT DEFAULT NULL, unit_price INT NOT NULL, flat_fee INT NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE INDEX IDX_E121B885D614C7E7 ON price_tier_component (price_id)');
        $this->addSql('COMMENT ON COLUMN price_tier_component.id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN price_tier_component.price_id IS \'(DC2Type:uuid)\'');
        $this->addSql('ALTER TABLE event ADD CONSTRAINT FK_3BAE0AA79395C3F3 FOREIGN KEY (customer_id) REFERENCES customers (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE event ADD CONSTRAINT FK_3BAE0AA79A1887DC FOREIGN KEY (subscription_id) REFERENCES subscription (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE event ADD CONSTRAINT FK_3BAE0AA7A952D583 FOREIGN KEY (metric_id) REFERENCES metric (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE invoice_delivery ADD CONSTRAINT FK_28A9B6482989F1FD FOREIGN KEY (invoice_id) REFERENCES invoice (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE invoice_delivery ADD CONSTRAINT FK_28A9B648EA1C5E18 FOREIGN KEY (invoice_delivery_settings_id) REFERENCES invoice_delivery_settings (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE invoice_delivery ADD CONSTRAINT FK_28A9B6489395C3F3 FOREIGN KEY (customer_id) REFERENCES customers (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE invoice_delivery_settings ADD CONSTRAINT FK_879A8A7C9395C3F3 FOREIGN KEY (customer_id) REFERENCES customers (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE invoice_metric_counter ADD CONSTRAINT FK_94B89AA952D583 FOREIGN KEY (metric_id) REFERENCES metric (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE invoice_metric_counter ADD CONSTRAINT FK_94B89A2989F1FD FOREIGN KEY (invoice_id) REFERENCES invoice (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE invoice_metric_counter ADD CONSTRAINT FK_94B89A4E05402E FOREIGN KEY (metric_counter_id) REFERENCES metric_counter (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE metric_counter ADD CONSTRAINT FK_E01686F6A952D583 FOREIGN KEY (metric_id) REFERENCES metric (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE metric_counter ADD CONSTRAINT FK_E01686F69395C3F3 FOREIGN KEY (customer_id) REFERENCES customers (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE metric_filter ADD CONSTRAINT FK_FF226429A952D583 FOREIGN KEY (metric_id) REFERENCES metric (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE price_tier_component ADD CONSTRAINT FK_E121B885D614C7E7 FOREIGN KEY (price_id) REFERENCES price (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('create extension if not exists timescaledb;');
        $this->addSql('SELECT create_hypertable(\'event\', by_range(\'created_at\'));');
        $this->addSql('ALTER TABLE brand_settings ADD support_email VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE brand_settings ADD support_phone_number VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE brand_settings ADD notification_settings_payment_failure BOOLEAN DEFAULT NULL');
        $this->addSql('ALTER TABLE customers ADD invoice_format VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE invoice ADD invoiced_metric_counter_id UUID DEFAULT NULL');
        $this->addSql('COMMENT ON COLUMN invoice.invoiced_metric_counter_id IS \'(DC2Type:uuid)\'');
        $this->addSql('ALTER TABLE invoice ADD CONSTRAINT FK_90651744EB2BB86C FOREIGN KEY (invoiced_metric_counter_id) REFERENCES invoice_metric_counter (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('CREATE INDEX IDX_90651744EB2BB86C ON invoice (invoiced_metric_counter_id)');
        $this->addSql('ALTER TABLE invoice_line ADD product_id UUID DEFAULT NULL');
        $this->addSql('ALTER TABLE invoice_line ADD net_price INT NOT NULL DEFAULT 0');
        $this->addSql('ALTER TABLE invoice_line ADD quantity DOUBLE PRECISION DEFAULT NULL');
        $this->addSql('COMMENT ON COLUMN invoice_line.product_id IS \'(DC2Type:uuid)\'');
        $this->addSql('ALTER TABLE invoice_line ADD CONSTRAINT FK_D3D1D6934584665A FOREIGN KEY (product_id) REFERENCES product (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('CREATE INDEX IDX_D3D1D6934584665A ON invoice_line (product_id)');
        $this->addSql('ALTER TABLE payment ADD payment_card_id UUID DEFAULT NULL');
        $this->addSql('COMMENT ON COLUMN payment.payment_card_id IS \'(DC2Type:uuid)\'');
        $this->addSql('ALTER TABLE payment ADD CONSTRAINT FK_6D28840D538594CA FOREIGN KEY (payment_card_id) REFERENCES payment_card (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('CREATE INDEX IDX_6D28840D538594CA ON payment (payment_card_id)');
        $this->addSql('ALTER TABLE price ADD metric_id UUID DEFAULT NULL');
        $this->addSql('ALTER TABLE price ADD usage BOOLEAN DEFAULT NULL');
        $this->addSql('ALTER TABLE price ADD units INT DEFAULT NULL');
        $this->addSql('ALTER TABLE price ADD type VARCHAR(255) NOT NULL DEFAULT \'fixed_price\'');
        $this->addSql('ALTER TABLE price ADD metric_type VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE price ALTER amount DROP NOT NULL');
        $this->addSql('COMMENT ON COLUMN price.metric_id IS \'(DC2Type:uuid)\'');
        $this->addSql('ALTER TABLE price ADD CONSTRAINT FK_CAC822D9A952D583 FOREIGN KEY (metric_id) REFERENCES metric (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('CREATE INDEX IDX_CAC822D9A952D583 ON price (metric_id)');
        $this->addSql('ALTER TABLE settings ADD tax_settings_validate_tax_number BOOLEAN DEFAULT NULL');
        $this->addSql('ALTER TABLE settings ADD tax_settings_vat_sense_enabled BOOLEAN DEFAULT NULL');
        $this->addSql('ALTER TABLE settings ADD tax_settings_vat_sense_api_key VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE tax_type ADD vat_sense_type VARCHAR(255) DEFAULT NULL');
        $this->addSql('CREATE TABLE usage_limits (id UUID NOT NULL, customer_id UUID DEFAULT NULL, amount INT NOT NULL, warning_level INT NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE INDEX IDX_C4C29C39395C3F3 ON usage_limits (customer_id)');
        $this->addSql('COMMENT ON COLUMN usage_limits.id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN usage_limits.customer_id IS \'(DC2Type:uuid)\'');
        $this->addSql('CREATE TABLE usage_warning (id UUID NOT NULL, customer_id UUID DEFAULT NULL, usage_limit_id UUID DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, start_of_period TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, end_of_period TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
        $this->addSql('CREATE INDEX IDX_1ECAEAD99395C3F3 ON usage_warning (customer_id)');
        $this->addSql('CREATE INDEX IDX_1ECAEAD92C0BC879 ON usage_warning (usage_limit_id)');
        $this->addSql('COMMENT ON COLUMN usage_warning.id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN usage_warning.customer_id IS \'(DC2Type:uuid)\'');
        $this->addSql('COMMENT ON COLUMN usage_warning.usage_limit_id IS \'(DC2Type:uuid)\'');
        $this->addSql('ALTER TABLE usage_limits ADD CONSTRAINT FK_C4C29C39395C3F3 FOREIGN KEY (customer_id) REFERENCES customers (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE usage_warning ADD CONSTRAINT FK_1ECAEAD99395C3F3 FOREIGN KEY (customer_id) REFERENCES customers (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE usage_warning ADD CONSTRAINT FK_1ECAEAD92C0BC879 FOREIGN KEY (usage_limit_id) REFERENCES usage_limits (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('ALTER TABLE customers ADD warning_level INT DEFAULT NULL');
        $this->addSql('ALTER TABLE invoice_line ALTER net_price DROP DEFAULT');
        $this->addSql('ALTER TABLE country ADD transaction_threshold INT DEFAULT NULL');
        $this->addSql('ALTER TABLE country ADD threshold_type VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE credit ADD accounting_reference VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE customers ADD accounting_reference VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE customers ADD customer_support_reference VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE customers ADD marketing_opt_in BOOLEAN DEFAULT NULL');
        $this->addSql('ALTER TABLE customers ADD newsletter_marketing_reference VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE customers ADD newsletter_announcement_reference VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE expiring_card_process ALTER error TYPE VARCHAR(9999)');
        $this->addSql('ALTER TABLE invoice ADD converted_amount_due INT DEFAULT NULL');
        $this->addSql('ALTER TABLE invoice ADD converted_total INT DEFAULT NULL');
        $this->addSql('ALTER TABLE invoice ADD converted_sub_total INT DEFAULT NULL');
        $this->addSql('ALTER TABLE invoice ADD converted_tax_total INT DEFAULT NULL');
        $this->addSql('ALTER TABLE invoice ADD accounting_reference VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE invoice_line ADD subscription_id UUID DEFAULT NULL');
        $this->addSql('ALTER TABLE invoice_line ADD converted_net_price INT DEFAULT NULL');
        $this->addSql('ALTER TABLE invoice_line ADD converted_total INT DEFAULT NULL');
        $this->addSql('ALTER TABLE invoice_line ADD converted_sub_total INT DEFAULT NULL');
        $this->addSql('ALTER TABLE invoice_line ADD converted_tax_total INT DEFAULT NULL');
        $this->addSql('COMMENT ON COLUMN invoice_line.subscription_id IS \'(DC2Type:uuid)\'');
        $this->addSql('ALTER TABLE invoice_line ADD CONSTRAINT FK_D3D1D6939A1887DC FOREIGN KEY (subscription_id) REFERENCES subscription (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('CREATE INDEX IDX_D3D1D6939A1887DC ON invoice_line (subscription_id)');
        $this->addSql('ALTER TABLE invoice_process ALTER error TYPE VARCHAR(9999)');
        $this->addSql('ALTER TABLE payment ADD accounting_reference VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE payment ADD converted_amount INT DEFAULT NULL');
        $this->addSql('ALTER TABLE payment ADD converted_currency VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE process_trial_converted ALTER error TYPE VARCHAR(9999)');
        $this->addSql('ALTER TABLE process_trial_ended ALTER error TYPE VARCHAR(9999)');
        $this->addSql('ALTER TABLE process_trial_started ALTER error TYPE VARCHAR(9999)');
        $this->addSql('ALTER TABLE receipt ADD payment_id UUID DEFAULT NULL');
        $this->addSql('ALTER TABLE receipt ADD converted_total INT DEFAULT NULL');
        $this->addSql('ALTER TABLE receipt ADD converted_sub_total INT DEFAULT NULL');
        $this->addSql('ALTER TABLE receipt ADD converted_tax_total INT DEFAULT NULL');
        $this->addSql('COMMENT ON COLUMN receipt.payment_id IS \'(DC2Type:uuid)\'');
        $this->addSql('ALTER TABLE receipt ADD CONSTRAINT FK_5399B6454C3A3BB FOREIGN KEY (payment_id) REFERENCES payment (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('CREATE INDEX IDX_5399B6454C3A3BB ON receipt (payment_id)');
        $this->addSql('ALTER TABLE receipt_line ADD subscription_id UUID DEFAULT NULL');
        $this->addSql('ALTER TABLE receipt_line ADD converted_total INT DEFAULT NULL');
        $this->addSql('ALTER TABLE receipt_line ADD converted_sub_total INT DEFAULT NULL');
        $this->addSql('ALTER TABLE receipt_line ADD converted_vat_total INT DEFAULT NULL');
        $this->addSql('COMMENT ON COLUMN receipt_line.subscription_id IS \'(DC2Type:uuid)\'');
        $this->addSql('ALTER TABLE receipt_line ADD CONSTRAINT FK_476F8F7A9A1887DC FOREIGN KEY (subscription_id) REFERENCES subscription (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('CREATE INDEX IDX_476F8F7A9A1887DC ON receipt_line (subscription_id)');
        $this->addSql('ALTER TABLE refund ADD accounting_reference VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE settings ADD accounting_integration_enabled BOOLEAN DEFAULT NULL');
        $this->addSql('ALTER TABLE settings ADD accounting_integration_integration VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE settings ADD accounting_integration_settings JSON DEFAULT NULL');
        $this->addSql('ALTER TABLE settings ADD accounting_integration_oauth_settings_state_secret VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE settings ADD accounting_integration_oauth_settings_access_token VARCHAR(2000) DEFAULT NULL');
        $this->addSql('ALTER TABLE settings ADD accounting_integration_oauth_settings_refresh_token VARCHAR(2000) DEFAULT NULL');
        $this->addSql('ALTER TABLE settings ADD accounting_integration_oauth_settings_expires_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
        $this->addSql('ALTER TABLE settings ADD customer_support_integration_enabled BOOLEAN DEFAULT NULL');
        $this->addSql('ALTER TABLE settings ADD customer_support_integration_integration VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE settings ADD customer_support_integration_settings JSON DEFAULT NULL');
        $this->addSql('ALTER TABLE settings ADD customer_support_integration_oauth_settings_state_secret VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE settings ADD customer_support_integration_oauth_settings_access_token VARCHAR(2000) DEFAULT NULL');
        $this->addSql('ALTER TABLE settings ADD customer_support_integration_oauth_settings_refresh_token VARCHAR(2000) DEFAULT NULL');
        $this->addSql('ALTER TABLE settings ADD customer_support_integration_oauth_settings_expires_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
        $this->addSql('ALTER TABLE settings ADD newsletter_integration_enabled BOOLEAN DEFAULT NULL');
        $this->addSql('ALTER TABLE settings ADD newsletter_integration_integration VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE settings ADD newsletter_integration_marketing_list_id VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE settings ADD newsletter_integration_announcement_list_id VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE settings ADD newsletter_integration_settings JSON DEFAULT NULL');
        $this->addSql('ALTER TABLE settings ADD newsletter_integration_oauth_settings_state_secret VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE settings ADD newsletter_integration_oauth_settings_access_token VARCHAR(2000) DEFAULT NULL');
        $this->addSql('ALTER TABLE settings ADD newsletter_integration_oauth_settings_refresh_token VARCHAR(2000) DEFAULT NULL');
        $this->addSql('ALTER TABLE settings ADD newsletter_integration_oauth_settings_expires_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
        $this->addSql('ALTER TABLE state ADD transaction_threshold INT DEFAULT NULL');
        $this->addSql('ALTER TABLE state ADD threshold_type VARCHAR(255) DEFAULT NULL');
        $this->addSql('ALTER TABLE vouchers_application ADD accounting_reference VARCHAR(255) DEFAULT NULL');
        $this->addSql('DROP INDEX event_created_at_idx');
        $this->addSql('ALTER TABLE invoice DROP CONSTRAINT fk_90651744eb2bb86c');
        $this->addSql('DROP INDEX idx_90651744eb2bb86c');
        $this->addSql('ALTER TABLE invoice DROP invoiced_metric_counter_id');
        $this->addSql('ALTER TABLE invoice_line ADD invoiced_metric_counter_id UUID DEFAULT NULL');
        $this->addSql('COMMENT ON COLUMN invoice_line.invoiced_metric_counter_id IS \'(DC2Type:uuid)\'');
        $this->addSql('ALTER TABLE invoice_line ADD CONSTRAINT FK_D3D1D693EB2BB86C FOREIGN KEY (invoiced_metric_counter_id) REFERENCES invoice_metric_counter (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('CREATE INDEX IDX_D3D1D693EB2BB86C ON invoice_line (invoiced_metric_counter_id)');
        $this->addSql('ALTER TABLE refund_created_process ALTER error TYPE TEXT');
    }

    public function down(Schema $schema): void
    {
        $this->addSql('CREATE SCHEMA public');
        $this->addSql('ALTER TABLE invoice DROP CONSTRAINT FK_90651744EB2BB86C');
        $this->addSql('ALTER TABLE price DROP CONSTRAINT FK_CAC822D9A952D583');
        $this->addSql('create extension if not exists timescaledb;');
        $this->addSql('ALTER TABLE event DROP CONSTRAINT FK_3BAE0AA79395C3F3');
        $this->addSql('ALTER TABLE event DROP CONSTRAINT FK_3BAE0AA79A1887DC');
        $this->addSql('ALTER TABLE event DROP CONSTRAINT FK_3BAE0AA7A952D583');
        $this->addSql('ALTER TABLE invoice_delivery DROP CONSTRAINT FK_28A9B6482989F1FD');
        $this->addSql('ALTER TABLE invoice_delivery DROP CONSTRAINT FK_28A9B648EA1C5E18');
        $this->addSql('ALTER TABLE invoice_delivery DROP CONSTRAINT FK_28A9B6489395C3F3');
        $this->addSql('ALTER TABLE invoice_delivery_settings DROP CONSTRAINT FK_879A8A7C9395C3F3');
        $this->addSql('ALTER TABLE invoice_metric_counter DROP CONSTRAINT FK_94B89AA952D583');
        $this->addSql('ALTER TABLE invoice_metric_counter DROP CONSTRAINT FK_94B89A2989F1FD');
        $this->addSql('ALTER TABLE invoice_metric_counter DROP CONSTRAINT FK_94B89A4E05402E');
        $this->addSql('ALTER TABLE metric_counter DROP CONSTRAINT FK_E01686F6A952D583');
        $this->addSql('ALTER TABLE metric_counter DROP CONSTRAINT FK_E01686F69395C3F3');
        $this->addSql('ALTER TABLE metric_filter DROP CONSTRAINT FK_FF226429A952D583');
        $this->addSql('ALTER TABLE price_tier_component DROP CONSTRAINT FK_E121B885D614C7E7');
        $this->addSql('DROP TABLE event');
        $this->addSql('DROP TABLE invoice_delivery');
        $this->addSql('DROP TABLE invoice_delivery_settings');
        $this->addSql('DROP TABLE invoice_metric_counter');
        $this->addSql('DROP TABLE metric');
        $this->addSql('DROP TABLE metric_counter');
        $this->addSql('DROP TABLE metric_filter');
        $this->addSql('DROP TABLE price_tier_component');
        $this->addSql('ALTER TABLE tax_type DROP vat_sense_type');
        $this->addSql('ALTER TABLE customers DROP invoice_format');
        $this->addSql('ALTER TABLE invoice_line DROP CONSTRAINT FK_D3D1D6934584665A');
        $this->addSql('DROP INDEX IDX_D3D1D6934584665A');
        $this->addSql('ALTER TABLE invoice_line DROP product_id');
        $this->addSql('ALTER TABLE invoice_line DROP net_price');
        $this->addSql('ALTER TABLE invoice_line DROP quantity');
        $this->addSql('DROP INDEX IDX_CAC822D9A952D583');
        $this->addSql('ALTER TABLE price DROP metric_id');
        $this->addSql('ALTER TABLE price DROP usage');
        $this->addSql('ALTER TABLE price DROP units');
        $this->addSql('ALTER TABLE price DROP type');
        $this->addSql('ALTER TABLE price DROP metric_type');
        $this->addSql('ALTER TABLE price ALTER amount SET NOT NULL');
        $this->addSql('ALTER TABLE settings DROP tax_settings_validate_tax_number');
        $this->addSql('ALTER TABLE settings DROP tax_settings_vat_sense_enabled');
        $this->addSql('ALTER TABLE settings DROP tax_settings_vat_sense_api_key');
        $this->addSql('ALTER TABLE payment DROP CONSTRAINT FK_6D28840D538594CA');
        $this->addSql('DROP INDEX IDX_6D28840D538594CA');
        $this->addSql('ALTER TABLE payment DROP payment_card_id');
        $this->addSql('ALTER TABLE brand_settings DROP support_email');
        $this->addSql('ALTER TABLE brand_settings DROP support_phone_number');
        $this->addSql('ALTER TABLE brand_settings DROP notification_settings_payment_failure');
        $this->addSql('DROP INDEX IDX_90651744EB2BB86C');
        $this->addSql('ALTER TABLE invoice DROP invoiced_metric_counter_id');
        $this->addSql('ALTER TABLE usage_limits DROP CONSTRAINT FK_C4C29C39395C3F3');
        $this->addSql('ALTER TABLE usage_warning DROP CONSTRAINT FK_1ECAEAD99395C3F3');
        $this->addSql('ALTER TABLE usage_warning DROP CONSTRAINT FK_1ECAEAD92C0BC879');
        $this->addSql('DROP TABLE usage_limits');
        $this->addSql('DROP TABLE usage_warning');
        $this->addSql('ALTER TABLE invoice_line ALTER net_price SET DEFAULT 0');
        $this->addSql('ALTER TABLE customers DROP warning_level');
        $this->addSql('ALTER TABLE vouchers_application DROP accounting_reference');
        $this->addSql('ALTER TABLE country DROP transaction_threshold');
        $this->addSql('ALTER TABLE country DROP threshold_type');
        $this->addSql('ALTER TABLE credit DROP accounting_reference');
        $this->addSql('ALTER TABLE invoice_process ALTER error TYPE VARCHAR(255)');
        $this->addSql('ALTER TABLE settings DROP accounting_integration_enabled');
        $this->addSql('ALTER TABLE settings DROP accounting_integration_integration');
        $this->addSql('ALTER TABLE settings DROP accounting_integration_settings');
        $this->addSql('ALTER TABLE settings DROP accounting_integration_oauth_settings_state_secret');
        $this->addSql('ALTER TABLE settings DROP accounting_integration_oauth_settings_access_token');
        $this->addSql('ALTER TABLE settings DROP accounting_integration_oauth_settings_refresh_token');
        $this->addSql('ALTER TABLE settings DROP accounting_integration_oauth_settings_expires_at');
        $this->addSql('ALTER TABLE settings DROP customer_support_integration_enabled');
        $this->addSql('ALTER TABLE settings DROP customer_support_integration_integration');
        $this->addSql('ALTER TABLE settings DROP customer_support_integration_settings');
        $this->addSql('ALTER TABLE settings DROP customer_support_integration_oauth_settings_state_secret');
        $this->addSql('ALTER TABLE settings DROP customer_support_integration_oauth_settings_access_token');
        $this->addSql('ALTER TABLE settings DROP customer_support_integration_oauth_settings_refresh_token');
        $this->addSql('ALTER TABLE settings DROP customer_support_integration_oauth_settings_expires_at');
        $this->addSql('ALTER TABLE settings DROP newsletter_integration_enabled');
        $this->addSql('ALTER TABLE settings DROP newsletter_integration_integration');
        $this->addSql('ALTER TABLE settings DROP newsletter_integration_marketing_list_id');
        $this->addSql('ALTER TABLE settings DROP newsletter_integration_announcement_list_id');
        $this->addSql('ALTER TABLE settings DROP newsletter_integration_settings');
        $this->addSql('ALTER TABLE settings DROP newsletter_integration_oauth_settings_state_secret');
        $this->addSql('ALTER TABLE settings DROP newsletter_integration_oauth_settings_access_token');
        $this->addSql('ALTER TABLE settings DROP newsletter_integration_oauth_settings_refresh_token');
        $this->addSql('ALTER TABLE settings DROP newsletter_integration_oauth_settings_expires_at');
        $this->addSql('ALTER TABLE refund DROP accounting_reference');
        $this->addSql('ALTER TABLE receipt_line DROP CONSTRAINT FK_476F8F7A9A1887DC');
        $this->addSql('DROP INDEX IDX_476F8F7A9A1887DC');
        $this->addSql('ALTER TABLE receipt_line DROP subscription_id');
        $this->addSql('ALTER TABLE receipt_line DROP converted_total');
        $this->addSql('ALTER TABLE receipt_line DROP converted_sub_total');
        $this->addSql('ALTER TABLE receipt_line DROP converted_vat_total');
        $this->addSql('ALTER TABLE state DROP transaction_threshold');
        $this->addSql('ALTER TABLE state DROP threshold_type');
        $this->addSql('ALTER TABLE customers DROP accounting_reference');
        $this->addSql('ALTER TABLE customers DROP customer_support_reference');
        $this->addSql('ALTER TABLE customers DROP marketing_opt_in');
        $this->addSql('ALTER TABLE customers DROP newsletter_marketing_reference');
        $this->addSql('ALTER TABLE customers DROP newsletter_announcement_reference');
        $this->addSql('ALTER TABLE receipt DROP CONSTRAINT FK_5399B6454C3A3BB');
        $this->addSql('DROP INDEX IDX_5399B6454C3A3BB');
        $this->addSql('ALTER TABLE receipt DROP payment_id');
        $this->addSql('ALTER TABLE receipt DROP converted_total');
        $this->addSql('ALTER TABLE receipt DROP converted_sub_total');
        $this->addSql('ALTER TABLE receipt DROP converted_tax_total');
        $this->addSql('ALTER TABLE invoice DROP converted_amount_due');
        $this->addSql('ALTER TABLE invoice DROP converted_total');
        $this->addSql('ALTER TABLE invoice DROP converted_sub_total');
        $this->addSql('ALTER TABLE invoice DROP converted_tax_total');
        $this->addSql('ALTER TABLE invoice DROP accounting_reference');
        $this->addSql('ALTER TABLE process_trial_ended ALTER error TYPE VARCHAR(255)');
        $this->addSql('ALTER TABLE payment DROP accounting_reference');
        $this->addSql('ALTER TABLE payment DROP converted_amount');
        $this->addSql('ALTER TABLE payment DROP converted_currency');
        $this->addSql('ALTER TABLE process_trial_started ALTER error TYPE VARCHAR(255)');
        $this->addSql('ALTER TABLE process_trial_converted ALTER error TYPE VARCHAR(255)');
        $this->addSql('ALTER TABLE expiring_card_process ALTER error TYPE VARCHAR(255)');
        $this->addSql('ALTER TABLE invoice_line DROP CONSTRAINT FK_D3D1D6939A1887DC');
        $this->addSql('DROP INDEX IDX_D3D1D6939A1887DC');
        $this->addSql('ALTER TABLE invoice_line DROP subscription_id');
        $this->addSql('ALTER TABLE invoice_line DROP converted_net_price');
        $this->addSql('ALTER TABLE invoice_line DROP converted_total');
        $this->addSql('ALTER TABLE invoice_line DROP converted_sub_total');
        $this->addSql('ALTER TABLE invoice_line DROP converted_tax_total');
        $this->addSql('ALTER TABLE invoice_line DROP CONSTRAINT FK_D3D1D693EB2BB86C');
        $this->addSql('DROP INDEX IDX_D3D1D693EB2BB86C');
        $this->addSql('ALTER TABLE invoice_line DROP invoiced_metric_counter_id');
        $this->addSql('CREATE INDEX event_created_at_idx ON event (created_at)');
        $this->addSql('ALTER TABLE refund_created_process ALTER error TYPE VARCHAR(255)');
        $this->addSql('ALTER TABLE invoice ADD invoiced_metric_counter_id UUID DEFAULT NULL');
        $this->addSql('COMMENT ON COLUMN invoice.invoiced_metric_counter_id IS \'(DC2Type:uuid)\'');
        $this->addSql('ALTER TABLE invoice ADD CONSTRAINT fk_90651744eb2bb86c FOREIGN KEY (invoiced_metric_counter_id) REFERENCES invoice_metric_counter (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
        $this->addSql('CREATE INDEX idx_90651744eb2bb86c ON invoice (invoiced_metric_counter_id)');
    }
}
