# Generated by Django 3.2.9 on 2021-12-09 16:28

from django.db import migrations

import gnosis.eth.django.models


class Migration(migrations.Migration):

    dependencies = [
        ("history", "0051_ethereum_address_field_v2_update"),
    ]
    operations = [
        migrations.RunSQL(
            """
            -- Alter field block_hash on ethereumblock
            --
            DROP INDEX IF EXISTS "history_ethereumblock_block_hash_106040a5_like";
            ALTER TABLE "history_ethereumblock" ALTER COLUMN "block_hash" TYPE bytea USING DECODE("block_hash", 'hex');
            --
            -- Alter field parent_hash on ethereumblock
            --
            DROP INDEX IF EXISTS "history_ethereumblock_parent_hash_9ffab967_like";
            ALTER TABLE "history_ethereumblock" ALTER COLUMN "parent_hash" TYPE bytea USING DECODE("parent_hash", 'hex');
            --
            -- Alter field tx_hash on ethereumtx
            --
            DROP INDEX IF EXISTS "history_ethereumtx_tx_hash_c3adab3a_like";
            SET CONSTRAINTS "history_erc721transf_ethereum_tx_id_aa020110_fk_history_e" IMMEDIATE; ALTER TABLE "history_erc721transfer" DROP CONSTRAINT "history_erc721transf_ethereum_tx_id_aa020110_fk_history_e";
            SET CONSTRAINTS "history_multisigtran_ethereum_tx_id_c8d3f1cf_fk_history_e" IMMEDIATE; ALTER TABLE "history_multisigtransaction" DROP CONSTRAINT "history_multisigtran_ethereum_tx_id_c8d3f1cf_fk_history_e";
            SET CONSTRAINTS "history_internaltx_ethereum_tx_id_e6ac35ab_fk_history_e" IMMEDIATE; ALTER TABLE "history_internaltx" DROP CONSTRAINT "history_internaltx_ethereum_tx_id_e6ac35ab_fk_history_e";
            SET CONSTRAINTS "history_safecontract_ethereum_tx_id_4f63f583_fk_history_e" IMMEDIATE; ALTER TABLE "history_safecontract" DROP CONSTRAINT "history_safecontract_ethereum_tx_id_4f63f583_fk_history_e";
            SET CONSTRAINTS "history_multisigconf_ethereum_tx_id_71e0ab73_fk_history_e" IMMEDIATE; ALTER TABLE "history_multisigconfirmation" DROP CONSTRAINT "history_multisigconf_ethereum_tx_id_71e0ab73_fk_history_e";
            SET CONSTRAINTS "history_erc20transfe_ethereum_tx_id_16a6036b_fk_history_e" IMMEDIATE; ALTER TABLE "history_erc20transfer" DROP CONSTRAINT "history_erc20transfe_ethereum_tx_id_16a6036b_fk_history_e";
            ALTER TABLE "history_ethereumtx" ALTER COLUMN "tx_hash" TYPE bytea USING DECODE("tx_hash", 'hex');
            ALTER TABLE "history_erc721transfer" ALTER COLUMN "ethereum_tx_id" TYPE bytea USING DECODE("ethereum_tx_id", 'hex');
            ALTER TABLE "history_multisigtransaction" ALTER COLUMN "ethereum_tx_id" TYPE bytea USING DECODE("ethereum_tx_id", 'hex');
            ALTER TABLE "history_internaltx" ALTER COLUMN "ethereum_tx_id" TYPE bytea USING DECODE("ethereum_tx_id", 'hex');
            ALTER TABLE "history_safecontract" ALTER COLUMN "ethereum_tx_id" TYPE bytea USING DECODE("ethereum_tx_id", 'hex');
            ALTER TABLE "history_multisigconfirmation" ALTER COLUMN "ethereum_tx_id" TYPE bytea USING DECODE("ethereum_tx_id", 'hex');
            ALTER TABLE "history_erc20transfer" ALTER COLUMN "ethereum_tx_id" TYPE bytea USING DECODE("ethereum_tx_id", 'hex');
            ALTER TABLE "history_erc721transfer" ADD CONSTRAINT "history_erc721transfer_ethereum_tx_id_aa020110_fk" FOREIGN KEY ("ethereum_tx_id") REFERENCES "history_ethereumtx" ("tx_hash") DEFERRABLE INITIALLY DEFERRED;
            ALTER TABLE "history_multisigtransaction" ADD CONSTRAINT "history_multisigtransaction_ethereum_tx_id_c8d3f1cf_fk" FOREIGN KEY ("ethereum_tx_id") REFERENCES "history_ethereumtx" ("tx_hash") DEFERRABLE INITIALLY DEFERRED;
            ALTER TABLE "history_internaltx" ADD CONSTRAINT "history_internaltx_ethereum_tx_id_e6ac35ab_fk" FOREIGN KEY ("ethereum_tx_id") REFERENCES "history_ethereumtx" ("tx_hash") DEFERRABLE INITIALLY DEFERRED;
            ALTER TABLE "history_safecontract" ADD CONSTRAINT "history_safecontract_ethereum_tx_id_4f63f583_fk" FOREIGN KEY ("ethereum_tx_id") REFERENCES "history_ethereumtx" ("tx_hash") DEFERRABLE INITIALLY DEFERRED;
            ALTER TABLE "history_multisigconfirmation" ADD CONSTRAINT "history_multisigconfirmation_ethereum_tx_id_71e0ab73_fk" FOREIGN KEY ("ethereum_tx_id") REFERENCES "history_ethereumtx" ("tx_hash") DEFERRABLE INITIALLY DEFERRED;
            ALTER TABLE "history_erc20transfer" ADD CONSTRAINT "history_erc20transfer_ethereum_tx_id_16a6036b_fk" FOREIGN KEY ("ethereum_tx_id") REFERENCES "history_ethereumtx" ("tx_hash") DEFERRABLE INITIALLY DEFERRED;
            --
            -- Alter field multisig_transaction_hash on multisigconfirmation
            --
            DROP INDEX IF EXISTS "history_multisigconfirma_multisig_transaction_has_4c8cbf7a_like";
            ALTER TABLE "history_multisigconfirmation" ALTER COLUMN "multisig_transaction_hash" TYPE bytea USING DECODE("multisig_transaction_hash", 'hex');
            --
            -- Alter field safe_tx_hash on multisigtransaction
            --
            DROP INDEX IF EXISTS "history_multisigtransaction_safe_tx_hash_4d740966_like";
            SET CONSTRAINTS "history_multisigconf_multisig_transaction_43ec94d5_fk_history_m" IMMEDIATE; ALTER TABLE "history_multisigconfirmation" DROP CONSTRAINT "history_multisigconf_multisig_transaction_43ec94d5_fk_history_m";
            ALTER TABLE "history_multisigtransaction" ALTER COLUMN "safe_tx_hash" TYPE bytea USING DECODE("safe_tx_hash", 'hex');
            ALTER TABLE "history_multisigconfirmation" ALTER COLUMN "multisig_transaction_id" TYPE bytea USING DECODE("multisig_transaction_id", 'hex');
            ALTER TABLE "history_multisigconfirmation" ADD CONSTRAINT "history_multisigconfirmat_multisig_transaction_id_43ec94d5_fk" FOREIGN KEY ("multisig_transaction_id") REFERENCES "history_multisigtransaction" ("safe_tx_hash") DEFERRABLE INITIALLY DEFERRED;
            -- End of custom migration
            """,
            reverse_sql=migrations.RunSQL.noop,
        ),
        migrations.AlterField(
            model_name="ethereumblock",
            name="block_hash",
            field=gnosis.eth.django.models.Keccak256Field(unique=True),
        ),
        migrations.AlterField(
            model_name="ethereumblock",
            name="parent_hash",
            field=gnosis.eth.django.models.Keccak256Field(unique=True),
        ),
        migrations.AlterField(
            model_name="ethereumtx",
            name="tx_hash",
            field=gnosis.eth.django.models.Keccak256Field(
                primary_key=True, serialize=False
            ),
        ),
        migrations.AlterField(
            model_name="multisigconfirmation",
            name="multisig_transaction_hash",
            field=gnosis.eth.django.models.Keccak256Field(db_index=True, null=True),
        ),
        migrations.AlterField(
            model_name="multisigtransaction",
            name="safe_tx_hash",
            field=gnosis.eth.django.models.Keccak256Field(
                primary_key=True, serialize=False
            ),
        ),
    ]

# Generated by Django 3.2.9 on 2021-12-09 16:28

from django.db import migrations

import gnosis.eth.django.models


class Migration(migrations.Migration):

    dependencies = [
        ("history", "0051_ethereum_address_field_v2_update"),
    ]
    operations = [
        migrations.RunSQL(
            """
            -- Alter field block_hash on ethereumblock
            --
            DROP INDEX IF EXISTS "history_ethereumblock_block_hash_106040a5_like";
            ALTER TABLE "history_ethereumblock" ALTER COLUMN "block_hash" TYPE bytea USING DECODE("block_hash", 'hex');
            --
            -- Alter field parent_hash on ethereumblock
            --
            DROP INDEX IF EXISTS "history_ethereumblock_parent_hash_9ffab967_like";
            ALTER TABLE "history_ethereumblock" ALTER COLUMN "parent_hash" TYPE bytea USING DECODE("parent_hash", 'hex');
            --
            -- Alter field tx_hash on ethereumtx
            --
            DROP INDEX IF EXISTS "history_ethereumtx_tx_hash_c3adab3a_like";
            SET CONSTRAINTS "history_erc721transf_ethereum_tx_id_aa020110_fk_history_e" IMMEDIATE; ALTER TABLE "history_erc721transfer" DROP CONSTRAINT "history_erc721transf_ethereum_tx_id_aa020110_fk_history_e";
            SET CONSTRAINTS "history_multisigtran_ethereum_tx_id_c8d3f1cf_fk_history_e" IMMEDIATE; ALTER TABLE "history_multisigtransaction" DROP CONSTRAINT "history_multisigtran_ethereum_tx_id_c8d3f1cf_fk_history_e";
            SET CONSTRAINTS "history_internaltx_ethereum_tx_id_e6ac35ab_fk_history_e" IMMEDIATE; ALTER TABLE "history_internaltx" DROP CONSTRAINT "history_internaltx_ethereum_tx_id_e6ac35ab_fk_history_e";
            SET CONSTRAINTS "history_safecontract_ethereum_tx_id_4f63f583_fk_history_e" IMMEDIATE; ALTER TABLE "history_safecontract" DROP CONSTRAINT "history_safecontract_ethereum_tx_id_4f63f583_fk_history_e";
            SET CONSTRAINTS "history_multisigconf_ethereum_tx_id_71e0ab73_fk_history_e" IMMEDIATE; ALTER TABLE "history_multisigconfirmation" DROP CONSTRAINT "history_multisigconf_ethereum_tx_id_71e0ab73_fk_history_e";
            SET CONSTRAINTS "history_erc20transfe_ethereum_tx_id_16a6036b_fk_history_e" IMMEDIATE; ALTER TABLE "history_erc20transfer" DROP CONSTRAINT "history_erc20transfe_ethereum_tx_id_16a6036b_fk_history_e";
            ALTER TABLE "history_ethereumtx" ALTER COLUMN "tx_hash" TYPE bytea USING DECODE("tx_hash", 'hex');
            ALTER TABLE "history_erc721transfer" ALTER COLUMN "ethereum_tx_id" TYPE bytea USING DECODE("ethereum_tx_id", 'hex');
            ALTER TABLE "history_multisigtransaction" ALTER COLUMN "ethereum_tx_id" TYPE bytea USING DECODE("ethereum_tx_id", 'hex');
            ALTER TABLE "history_internaltx" ALTER COLUMN "ethereum_tx_id" TYPE bytea USING DECODE("ethereum_tx_id", 'hex');
            ALTER TABLE "history_safecontract" ALTER COLUMN "ethereum_tx_id" TYPE bytea USING DECODE("ethereum_tx_id", 'hex');
            ALTER TABLE "history_multisigconfirmation" ALTER COLUMN "ethereum_tx_id" TYPE bytea USING DECODE("ethereum_tx_id", 'hex');
            ALTER TABLE "history_erc20transfer" ALTER COLUMN "ethereum_tx_id" TYPE bytea USING DECODE("ethereum_tx_id", 'hex');
            ALTER TABLE "history_erc721transfer" ADD CONSTRAINT "history_erc721transfer_ethereum_tx_id_aa020110_fk" FOREIGN KEY ("ethereum_tx_id") REFERENCES "history_ethereumtx" ("tx_hash") DEFERRABLE INITIALLY DEFERRED;
            ALTER TABLE "history_multisigtransaction" ADD CONSTRAINT "history_multisigtransaction_ethereum_tx_id_c8d3f1cf_fk" FOREIGN KEY ("ethereum_tx_id") REFERENCES "history_ethereumtx" ("tx_hash") DEFERRABLE INITIALLY DEFERRED;
            ALTER TABLE "history_internaltx" ADD CONSTRAINT "history_internaltx_ethereum_tx_id_e6ac35ab_fk" FOREIGN KEY ("ethereum_tx_id") REFERENCES "history_ethereumtx" ("tx_hash") DEFERRABLE INITIALLY DEFERRED;
            ALTER TABLE "history_safecontract" ADD CONSTRAINT "history_safecontract_ethereum_tx_id_4f63f583_fk" FOREIGN KEY ("ethereum_tx_id") REFERENCES "history_ethereumtx" ("tx_hash") DEFERRABLE INITIALLY DEFERRED;
            ALTER TABLE "history_multisigconfirmation" ADD CONSTRAINT "history_multisigconfirmation_ethereum_tx_id_71e0ab73_fk" FOREIGN KEY ("ethereum_tx_id") REFERENCES "history_ethereumtx" ("tx_hash") DEFERRABLE INITIALLY DEFERRED;
            ALTER TABLE "history_erc20transfer" ADD CONSTRAINT "history_erc20transfer_ethereum_tx_id_16a6036b_fk" FOREIGN KEY ("ethereum_tx_id") REFERENCES "history_ethereumtx" ("tx_hash") DEFERRABLE INITIALLY DEFERRED;
            --
            -- Alter field multisig_transaction_hash on multisigconfirmation
            --
            DROP INDEX IF EXISTS "history_multisigconfirma_multisig_transaction_has_4c8cbf7a_like";
            ALTER TABLE "history_multisigconfirmation" ALTER COLUMN "multisig_transaction_hash" TYPE bytea USING DECODE("multisig_transaction_hash", 'hex');
            --
            -- Alter field safe_tx_hash on multisigtransaction
            --
            DROP INDEX IF EXISTS "history_multisigtransaction_safe_tx_hash_4d740966_like";
            SET CONSTRAINTS "history_multisigconf_multisig_transaction_43ec94d5_fk_history_m" IMMEDIATE; ALTER TABLE "history_multisigconfirmation" DROP CONSTRAINT "history_multisigconf_multisig_transaction_43ec94d5_fk_history_m";
            ALTER TABLE "history_multisigtransaction" ALTER COLUMN "safe_tx_hash" TYPE bytea USING DECODE("safe_tx_hash", 'hex');
            ALTER TABLE "history_multisigconfirmation" ALTER COLUMN "multisig_transaction_id" TYPE bytea USING DECODE("multisig_transaction_id", 'hex');
            ALTER TABLE "history_multisigconfirmation" ADD CONSTRAINT "history_multisigconfirmat_multisig_transaction_id_43ec94d5_fk" FOREIGN KEY ("multisig_transaction_id") REFERENCES "history_multisigtransaction" ("safe_tx_hash") DEFERRABLE INITIALLY DEFERRED;
            -- End of custom migration
            """,
            reverse_sql=migrations.RunSQL.noop,
        ),
        migrations.AlterField(
            model_name="ethereumblock",
            name="block_hash",
            field=gnosis.eth.django.models.Keccak256Field(unique=True),
        ),
        migrations.AlterField(
            model_name="ethereumblock",
            name="parent_hash",
            field=gnosis.eth.django.models.Keccak256Field(unique=True),
        ),
        migrations.AlterField(
            model_name="ethereumtx",
            name="tx_hash",
            field=gnosis.eth.django.models.Keccak256Field(
                primary_key=True, serialize=False
            ),
        ),
        migrations.AlterField(
            model_name="multisigconfirmation",
            name="multisig_transaction_hash",
            field=gnosis.eth.django.models.Keccak256Field(db_index=True, null=True),
        ),
        migrations.AlterField(
            model_name="multisigtransaction",
            name="safe_tx_hash",
            field=gnosis.eth.django.models.Keccak256Field(
                primary_key=True, serialize=False
            ),
        ),
    ]

# Generated by Django 3.2.9 on 2021-12-09 16:28 -- Alter field block_hash on ethereumblock             --             DROP INDEX IF EXISTS "history_ethereumblock_block_hash_106040a5_like";             ALTER TABLE "history_ethereumblock" ALTER COLUMN "block_hash" TYPE bytea USING DECODE("block_hash", 'hex');             --             -- Alter field parent_hash on ethereumblock             --             DROP INDEX IF EXISTS "history_ethereumblock_parent_hash_9ffab967_like";             ALTER TABLE "history_ethereumblock" ALTER COLUMN "parent_hash" TYPE bytea USING DECODE("parent_hash", 'hex');             --             -- Alter field tx_hash on ethereumtx             --             DROP INDEX IF EXISTS "history_ethereumtx_tx_hash_c3adab3a_like";             SET CONSTRAINTS "history_erc721transf_ethereum_tx_id_aa020110_fk_history_e" IMMEDIATE; ALTER TABLE "history_erc721transfer" DROP CONSTRAINT "history_erc721transf_ethereum_tx_id_aa020110_fk_history_e";             SET CONSTRAINTS "history_multisigtran_ethereum_tx_id_c8d3f1cf_fk_history_e" IMMEDIATE; ALTER TABLE "history_multisigtransaction" DROP CONSTRAINT "history_multisigtran_ethereum_tx_id_c8d3f1cf_fk_history_e";             SET CONSTRAINTS "history_internaltx_ethereum_tx_id_e6ac35ab_fk_history_e" IMMEDIATE; ALTER TABLE "history_internaltx" DROP CONSTRAINT "history_internaltx_ethereum_tx_id_e6ac35ab_fk_history_e";             SET CONSTRAINTS "history_safecontract_ethereum_tx_id_4f63f583_fk_history_e" IMMEDIATE; ALTER TABLE "history_safecontract" DROP CONSTRAINT "history_safecontract_ethereum_tx_id_4f63f583_fk_history_e";             SET CONSTRAINTS "history_multisigconf_ethereum_tx_id_71e0ab73_fk_history_e" IMMEDIATE; ALTER TABLE "history_multisigconfirmation" DROP CONSTRAINT "history_multisigconf_ethereum_tx_id_71e0ab73_fk_history_e";             SET CONSTRAINTS "history_erc20transfe_ethereum_tx_id_16a6036b_fk_history_e" IMMEDIATE; ALTER TABLE "history_erc20transfer" DROP CONSTRAINT "history_erc20transfe_ethereum_tx_id_16a6036b_fk_history_e";             ALTER TABLE "history_ethereumtx" ALTER COLUMN "tx_hash" TYPE bytea USING DECODE("tx_hash", 'hex');             ALTER TABLE "history_erc721transfer" ALTER COLUMN "ethereum_tx_id" TYPE bytea USING DECODE("ethereum_tx_id", 'hex');             ALTER TABLE "history_multisigtransaction" ALTER COLUMN "ethereum_tx_id" TYPE bytea USING DECODE("ethereum_tx_id", 'hex');             ALTER TABLE "history_internaltx" ALTER COLUMN "ethereum_tx_id" TYPE bytea USING DECODE("ethereum_tx_id", 'hex');             ALTER TABLE "history_safecontract" ALTER COLUMN "ethereum_tx_id" TYPE bytea USING DECODE("ethereum_tx_id", 'hex');             ALTER TABLE "history_multisigconfirmation" ALTER COLUMN "ethereum_tx_id" TYPE bytea USING DECODE("ethereum_tx_id", 'hex');             ALTER TABLE "history_erc20transfer" ALTER COLUMN "ethereum_tx_id" TYPE bytea USING DECODE("ethereum_tx_id", 'hex');             ALTER TABLE "history_erc721transfer" ADD CONSTRAINT "history_erc721transfer_ethereum_tx_id_aa020110_fk" FOREIGN KEY ("ethereum_tx_id") REFERENCES "history_ethereumtx" ("tx_hash") DEFERRABLE INITIALLY DEFERRED;             ALTER TABLE "history_multisigtransaction" ADD CONSTRAINT "history_multisigtransaction_ethereum_tx_id_c8d3f1cf_fk" FOREIGN KEY ("ethereum_tx_id") REFERENCES "history_ethereumtx" ("tx_hash") DEFERRABLE INITIALLY DEFERRED;             ALTER TABLE "history_internaltx" ADD CONSTRAINT "history_internaltx_ethereum_tx_id_e6ac35ab_fk" FOREIGN KEY ("ethereum_tx_id") REFERENCES "history_ethereumtx" ("tx_hash") DEFERRABLE INITIALLY DEFERRED;             ALTER TABLE "history_safecontract" ADD CONSTRAINT "history_safecontract_ethereum_tx_id_4f63f583_fk" FOREIGN KEY ("ethereum_tx_id") REFERENCES "history_ethereumtx" ("tx_hash") DEFERRABLE INITIALLY DEFERRED;             ALTER TABLE "history_multisigconfirmation" ADD CONSTRAINT "history_multisigconfirmation_ethereum_tx_id_71e0ab73_fk" FOREIGN KEY ("ethereum_tx_id") REFERENCES "history_ethereumtx" ("tx_hash") DEFERRABLE INITIALLY DEFERRED;             ALTER TABLE "history_erc20transfer" ADD CONSTRAINT "history_erc20transfer_ethereum_tx_id_16a6036b_fk" FOREIGN KEY ("ethereum_tx_id") REFERENCES "history_ethereumtx" ("tx_hash") DEFERRABLE INITIALLY DEFERRED;             --             -- Alter field multisig_transaction_hash on multisigconfirmation             --             DROP INDEX IF EXISTS "history_multisigconfirma_multisig_transaction_has_4c8cbf7a_like";             ALTER TABLE "history_multisigconfirmation" ALTER COLUMN "multisig_transaction_hash" TYPE bytea USING DECODE("multisig_transaction_hash", 'hex');             --             -- Alter field safe_tx_hash on multisigtransaction             --             DROP INDEX IF EXISTS "history_multisigtransaction_safe_tx_hash_4d740966_like";             SET CONSTRAINTS "history_multisigconf_multisig_transaction_43ec94d5_fk_history_m" IMMEDIATE; ALTER TABLE "history_multisigconfirmation" DROP CONSTRAINT "history_multisigconf_multisig_transaction_43ec94d5_fk_history_m";             ALTER TABLE "history_multisigtransaction" ALTER COLUMN "safe_tx_hash" TYPE bytea USING DECODE("safe_tx_hash", 'hex');             ALTER TABLE "history_multisigconfirmation" ALTER COLUMN "multisig_transaction_id" TYPE bytea USING DECODE("multisig_transaction_id", 'hex');             ALTER TABLE "history_multisigconfirmation" ADD CONSTRAINT "history_multisigconfirmat_multisig_transaction_id_43ec94d5_fk" FOREIGN KEY ("multisig_transaction_id") REFERENCES "history_multisigtransaction" ("safe_tx_hash") DEFERRABLE INITIALLY DEFERRED;             -- End of custom migration