Beispiel #1
0
def test_upgrade(app):
    alembic = Alembic(app)
    alembic.upgrade()
    alembic.downgrade(target='a82a46d12408')

    # fddb3cfe7a9c

    alembic.upgrade(target='fddb3cfe7a9c')

    assert 'inspire_prod_records' in _get_table_names()
    assert 'inspire_prod_records_recid_seq' in _get_sequences()
    assert 'workflows_audit_logging' in _get_table_names()
    assert 'workflows_audit_logging_id_seq' in _get_sequences()
    assert 'workflows_pending_record' in _get_table_names()

    # cb9f81e8251c

    alembic.upgrade(target='cb9f81e8251c')

    assert 'idxgindoctype' in _get_indexes('records_metadata')
    assert 'idxgintitles' in _get_indexes('records_metadata')
    assert 'idxginjournaltitle' in _get_indexes('records_metadata')
    assert 'idxgincollections' in _get_indexes('records_metadata')

    # cb5153afd839

    alembic.downgrade(target='fddb3cfe7a9c')
    alembic.upgrade(target='cb5153afd839')

    assert 'workflows_record_sources' in _get_table_names()

    # d99c70308006

    alembic.upgrade(target='d99c70308006')

    # 53e8594bc789

    alembic.upgrade(target='53e8594bc789')

    # 402af3fbf68b

    alembic.upgrade(target='402af3fbf68b')

    assert 'inspire_prod_records' not in _get_table_names()
    assert 'inspire_prod_records_recid_seq' not in _get_sequences()
    assert 'legacy_records_mirror' in _get_table_names()
    assert 'legacy_records_mirror_recid_seq' in _get_sequences()

    # 17ff155db70d

    alembic.upgrade(target="17ff155db70d")
    # Not checking as it only adds or modifies columns

    # f9ea5752e7a5

    alembic.upgrade(target="f9ea5752e7a5")
    # Not checking as it only adds or modifies columns

    # eaab22c59b89
    alembic.upgrade(target="eaab22c59b89")

    # 2f5368ff6d20
    alembic.upgrade(target="2f5368ff6d20")
    # TODO Create proper tests for 2f5368ff6d20, eaab22c59b89, f9ea5752e7a5,
    # 17ff155db70d

    # 0bc0a6ee1bc0

    alembic.upgrade(target='0bc0a6ee1bc0')

    assert 'ix_records_metadata_json_referenced_records' in _get_indexes(
        'records_metadata')
Beispiel #2
0
def test_downgrade(isolated_app):
    alembic = Alembic(isolated_app)
    alembic.upgrade()

    # downgrade 0bc0a6ee1bc0 == downgrade to 2f5368ff6d20

    alembic.downgrade(target='2f5368ff6d20')
    assert 'ix_records_metadata_json_referenced_records' not in _get_indexes(
        'records_metadata')

    # 2f5368ff6d20
    # TODO |Create proper tests for 2f5368ff6d20, eaab22c59b89, f9ea5752e7a5
    # TODO | and 17ff155db70d

    alembic.downgrade(target="eaab22c59b89")

    # eaab22c59b89
    alembic.downgrade(target="f9ea5752e7a5")

    # f9ea5752e7a5

    alembic.downgrade(target="17ff155db70d")

    # 17ff155db70d

    alembic.downgrade(target="402af3fbf68b")

    # 402af3fbf68b

    alembic.downgrade(target='53e8594bc789')

    # 53e8594bc789

    alembic.downgrade(target='d99c70308006')

    assert 'inspire_prod_records' in _get_table_names()
    assert 'inspire_prod_records_recid_seq' in _get_sequences()
    assert 'legacy_records_mirror' not in _get_table_names()
    assert 'legacy_records_mirror_recid_seq' not in _get_sequences()

    # d99c70308006

    alembic.downgrade(target='cb9f81e8251c')
    alembic.downgrade(target='cb5153afd839')

    # cb9f81e8251c & cb5153afd839

    alembic.downgrade(target='fddb3cfe7a9c')

    assert 'idxgindoctype' not in _get_indexes('records_metadata')
    assert 'idxgintitles' not in _get_indexes('records_metadata')
    assert 'idxginjournaltitle' not in _get_indexes('records_metadata')
    assert 'idxgincollections' not in _get_indexes('records_metadata')

    assert 'workflows_record_sources' not in _get_table_names()

    # fddb3cfe7a9c

    alembic.downgrade(target='a82a46d12408')

    assert 'inspire_prod_records' not in _get_table_names()
    assert 'inspire_prod_records_recid_seq' not in _get_sequences()
    assert 'workflows_audit_logging' not in _get_table_names()
    assert 'workflows_audit_logging_id_seq' not in _get_sequences()
    assert 'workflows_pending_record' not in _get_table_names()
def test_downgrade(inspire_app):
    alembic = Alembic(current_app)
    alembic.downgrade(target="318758a589d5")
    assert "cds_runs" not in _get_table_names()
    assert "enum_cds_run_status" not in _get_custom_enums()
    assert "ix_cds_runs_status_date" not in _get_indexes("cds_runs")

    alembic.downgrade(target="49a436a179ac")
    assert "idx_object" in _get_indexes("pidstore_pid")
    assert "object_type, object_uuid" in _get_index_definition(
        "pidstore_pid", "idx_object"
    )

    alembic.downgrade(target="c9f31d2a189d")
    assert "ix_inspire_pidstore_redirect_new_pid_id" not in _get_indexes(
        "inspire_pidstore_redirect"
    )
    assert "ix_inspire_pidstore_redirect_original_pid_id" not in _get_indexes(
        "inspire_pidstore_redirect"
    )
    assert "inspire_pidstore_redirect" not in _get_table_names()

    alembic.downgrade(target="020b99d0beb7")

    assert "ix_experiment_literature_literature_uuid" not in _get_indexes(
        "experiment_literature"
    )
    assert "ix_experiment_literature_experiment_uuid" not in _get_indexes(
        "experiment_literature"
    )
    assert "experiment_literature" not in _get_table_names()

    alembic.downgrade(target="8ba47044154a")
    assert "ix_records_authors_id_type_record_id" not in _get_indexes("records_authors")

    alembic.downgrade(target="5a0e2405b624")
    assert "ix_records_citations_cited_id_citation_type" not in _get_indexes(
        "records_citations"
    )
    assert "ix_records_citations_citer_id_citation_type" not in _get_indexes(
        "records_citations"
    )

    alembic.downgrade(target="595c36d68964")
    assert _check_column_in_table("records_citations", "is_self_citation") is False

    alembic.downgrade(target="cea5fa2e5d2c")

    assert "records_authors" not in _get_table_names()

    assert "ix_records_citations_cited_id" in _get_indexes("records_citations")
    assert "ix_records_citations_cited_id_citer_id" not in _get_indexes(
        "records_citations"
    )

    alembic.downgrade("b0cdab232269")

    assert "institution_literature" not in _get_table_names()
    assert "ix_institution_literature_literature_uuid" not in _get_indexes(
        "institution_literature"
    )
    assert "ix_institution_literature_institution_uuid" not in _get_indexes(
        "institution_literature"
    )

    alembic.downgrade("e5e43ad8f861")

    assert "idx_pidstore_pid_pid_value" not in _get_indexes("pidstore_pid")

    alembic.downgrade(target="f563233434cd")

    assert "enum_conference_to_literature_relationship_type" not in _get_custom_enums()
    assert "conference_literature" not in _get_table_names()
    assert "ix_conference_literature_literature_uuid" not in _get_indexes(
        "conference_literature"
    )
    assert "ix_conference_literature_conference_uuid" not in _get_indexes(
        "conference_literature"
    )

    alembic.downgrade(target="788a3a61a635")

    assert "idx_pid_provider" not in _get_indexes("pidstore_pid")

    alembic.downgrade(target="dc1ae5abe9d6")

    assert "idx_pid_provider" in _get_indexes("pidstore_pid")

    alembic.downgrade(target="c6570e49b7b2")

    assert "records_citations" in _get_table_names()
    assert "ix_records_citations_cited_id" in _get_indexes("records_citations")

    alembic.downgrade(target="5ce9ef759ace")

    assert "record_citations" in _get_table_names()
    assert "records_citations" not in _get_table_names()
    assert "ix_records_citations_cited_id" not in _get_indexes("record_citations")
    assert "idx_citations_cited" in _get_indexes("record_citations")

    alembic.downgrade(target="b646d3592dd5")
    assert "ix_legacy_records_mirror_last_updated" not in _get_indexes(
        "legacy_records_mirror"
    )
    assert "ix_legacy_records_mirror_valid_collection" not in _get_indexes(
        "legacy_records_mirror"
    )
    assert "legacy_records_mirror" not in _get_table_names()

    alembic.downgrade(target="7be4c8b5c5e8")
    assert "idx_citations_cited" not in _get_indexes("record_citations")

    assert "record_citations" not in _get_table_names()
Beispiel #4
0
def test_upgrade(inspire_app):
    alembic = Alembic(current_app)
    # go down to first migration
    alembic.downgrade(target="b5be5fda2ee7")

    alembic.upgrade(target="b646d3592dd5")

    assert "idx_citations_cited" in _get_indexes("record_citations")

    assert "record_citations" in _get_table_names()

    alembic.upgrade(target="5ce9ef759ace")

    assert "ix_legacy_records_mirror_last_updated" in _get_indexes(
        "legacy_records_mirror")
    assert "ix_legacy_records_mirror_valid_collection" in _get_indexes(
        "legacy_records_mirror")
    assert "legacy_records_mirror" in _get_table_names()

    alembic.upgrade(target="c6570e49b7b2")

    assert "records_citations" in _get_table_names()
    assert "record_citations" not in _get_table_names()

    assert "ix_records_citations_cited_id" in _get_indexes("records_citations")
    assert "idx_citations_cited" not in _get_indexes("records_citations")

    alembic.upgrade(target="dc1ae5abe9d6")

    assert "idx_pid_provider" in _get_indexes("pidstore_pid")

    alembic.upgrade(target="788a3a61a635")

    assert "idx_pid_provider" not in _get_indexes("pidstore_pid")

    alembic.upgrade(target="f563233434cd")

    assert "conference_literature" in _get_table_names()
    assert "ix_conference_literature_literature_uuid" in _get_indexes(
        "conference_literature")
    assert "ix_conference_literature_conference_uuid" in _get_indexes(
        "conference_literature")
    assert "enum_conference_to_literature_relationship_type" in _get_custom_enums(
    )

    alembic.upgrade(target="b0cdab232269")

    assert "idx_pidstore_pid_pid_value" in _get_indexes("pidstore_pid")

    alembic.upgrade(target="cea5fa2e5d2c")

    assert "institution_literature" in _get_table_names()
    assert "ix_institution_literature_literature_uuid" in _get_indexes(
        "institution_literature")
    assert "ix_institution_literature_institution_uuid" in _get_indexes(
        "institution_literature")

    alembic.upgrade(target="595c36d68964")

    assert "records_authors" in _get_table_names()
    assert "ix_authors_records_author_id_id_type_record_id" in _get_indexes(
        "records_authors")
    assert "ix_authors_records_record_id" in _get_indexes("records_authors")

    assert "ix_records_citations_cited_id" not in _get_indexes(
        "records_citations")
    assert "ix_records_citations_cited_id_citer_id" in _get_indexes(
        "records_citations")

    alembic.upgrade(target="5a0e2405b624")
    assert _check_column_in_table("records_citations",
                                  "is_self_citation") is True

    alembic.upgrade(target="8ba47044154a")
    assert "ix_records_citations_cited_id_citation_type" in _get_indexes(
        "records_citations")
    assert "ix_records_citations_citer_id_citation_type" in _get_indexes(
        "records_citations")

    alembic.upgrade(target="020b99d0beb7")
    assert "ix_records_authors_id_type_record_id" in _get_indexes(
        "records_authors")

    alembic.upgrade(target="afe5f484abcc")

    assert "experiment_literature" in _get_table_names()

    assert "ix_experiment_literature_literature_uuid" in _get_indexes(
        "experiment_literature")
    assert "ix_experiment_literature_experiment_uuid" in _get_indexes(
        "experiment_literature")

    alembic.upgrade(target="49a436a179ac")
    assert "inspire_pidstore_redirect" in _get_table_names()
    assert "ix_inspire_pidstore_redirect_new_pid_id" in _get_indexes(
        "inspire_pidstore_redirect")
    assert "ix_inspire_pidstore_redirect_original_pid_id" in _get_indexes(
        "inspire_pidstore_redirect")

    alembic.upgrade(target="318758a589d5")
    assert "idx_object" in _get_indexes("pidstore_pid")
    assert "object_uuid, object_type" in _get_index_definition(
        "pidstore_pid", "idx_object")

    alembic.upgrade(target="412aeb064d68")
    assert "cds_runs" in _get_table_names()
    assert "enum_cds_run_status" in _get_custom_enums()
    assert "ix_cds_runs_status_date" in _get_indexes("cds_runs")

    alembic.upgrade(target="2d7ea622feda")
    assert "ix_records_authors_id_type_authors_id" in _get_indexes(
        "records_authors")

    alembic.upgrade(target="232af38d2604")
    assert "students_advisors" in _get_table_names()
    assert "enum_degree_type" in _get_custom_enums()
    assert "ix_students_advisors_student_id" in _get_indexes(
        "students_advisors")
Beispiel #5
0
def test_upgrade(base_app, db, es):
    alembic = Alembic(base_app)
    # go down to first migration
    alembic.downgrade(target="b5be5fda2ee7")

    alembic.upgrade(target="7be4c8b5c5e8")

    assert "workflows_record_sources" in _get_table_names(db)
    assert "workflows_pending_record" in _get_table_names(db)
    assert "crawler_workflows_object" in _get_table_names(db)
    assert "crawler_job" in _get_table_names(db)
    assert "workflows_audit_logging" in _get_table_names(db)
    assert "workflows_buckets" in _get_table_names(db)
    assert "workflows_object" in _get_table_names(db)
    assert "workflows_workflow" in _get_table_names(db)

    assert "ix_crawler_job_job_id" in _get_indexes("crawler_job", db)
    assert "ix_crawler_job_scheduled" in _get_indexes("crawler_job", db)
    assert "ix_crawler_job_spider" in _get_indexes("crawler_job", db)
    assert "ix_crawler_job_workflow" in _get_indexes("crawler_job", db)
    assert "ix_workflows_audit_logging_object_id" in _get_indexes(
        "workflows_audit_logging", db
    )
    assert "ix_workflows_audit_logging_user_id" in _get_indexes(
        "workflows_audit_logging", db
    )
    assert "ix_workflows_object_data_type" in _get_indexes("workflows_object", db)
    assert "ix_workflows_object_id_parent" in _get_indexes("workflows_object", db)
    assert "ix_workflows_object_id_workflow" in _get_indexes("workflows_object", db)
    assert "ix_workflows_object_status" in _get_indexes("workflows_object", db)

    assert "ix_records_metadata_json_referenced_records_2_0" in _get_indexes(
        "records_metadata", db
    )

    alembic.upgrade(target="b646d3592dd5")

    assert "idx_citations_cited" in _get_indexes("record_citations", db)

    assert "record_citations" in _get_table_names(db)

    alembic.upgrade(target="5ce9ef759ace")

    assert "ix_legacy_records_mirror_last_updated" in _get_indexes(
        "legacy_records_mirror", db
    )
    assert "ix_legacy_records_mirror_valid_collection" in _get_indexes(
        "legacy_records_mirror", db
    )
    assert "legacy_records_mirror" in _get_table_names(db)

    alembic.upgrade(target="c6570e49b7b2")

    assert "records_citations" in _get_table_names(db)
    assert "record_citations" not in _get_table_names(db)

    assert "ix_records_citations_cited_id" in _get_indexes("records_citations", db)
    assert "idx_citations_cited" not in _get_indexes("records_citations", db)

    alembic.upgrade(target="dc1ae5abe9d6")

    assert "idx_pid_provider" in _get_indexes("pidstore_pid", db)

    alembic.upgrade(target="788a3a61a635")

    assert "idx_pid_provider" not in _get_indexes("pidstore_pid", db)
Beispiel #6
0
def test_upgrade(inspire_app):
    alembic = Alembic(current_app)
    # go down to first migration
    alembic.downgrade(target="b5be5fda2ee7")

    alembic.upgrade(target="b646d3592dd5")

    assert "idx_citations_cited" in _get_indexes("record_citations")

    assert "record_citations" in _get_table_names()

    alembic.upgrade(target="5ce9ef759ace")

    assert "ix_legacy_records_mirror_last_updated" in _get_indexes(
        "legacy_records_mirror"
    )
    assert "ix_legacy_records_mirror_valid_collection" in _get_indexes(
        "legacy_records_mirror"
    )
    assert "legacy_records_mirror" in _get_table_names()

    alembic.upgrade(target="c6570e49b7b2")

    assert "records_citations" in _get_table_names()
    assert "record_citations" not in _get_table_names()

    assert "ix_records_citations_cited_id" in _get_indexes("records_citations")
    assert "idx_citations_cited" not in _get_indexes("records_citations")

    alembic.upgrade(target="dc1ae5abe9d6")

    assert "idx_pid_provider" in _get_indexes("pidstore_pid")

    alembic.upgrade(target="788a3a61a635")

    assert "idx_pid_provider" not in _get_indexes("pidstore_pid")

    alembic.upgrade(target="f563233434cd")

    assert "conference_literature" in _get_table_names()
    assert "ix_conference_literature_literature_uuid" in _get_indexes(
        "conference_literature"
    )
    assert "ix_conference_literature_conference_uuid" in _get_indexes(
        "conference_literature"
    )
    assert "enum_conference_to_literature_relationship_type" in _get_custom_enums()

    alembic.upgrade(target="b0cdab232269")

    assert "idx_pidstore_pid_pid_value" in _get_indexes("pidstore_pid")

    alembic.upgrade(target="cea5fa2e5d2c")

    assert "institution_literature" in _get_table_names()
    assert "ix_institution_literature_literature_uuid" in _get_indexes(
        "institution_literature"
    )
    assert "ix_institution_literature_institution_uuid" in _get_indexes(
        "institution_literature"
    )

    alembic.upgrade(target="595c36d68964")

    assert "records_authors" in _get_table_names()
    assert "ix_authors_records_author_id_id_type_record_id" in _get_indexes(
        "records_authors"
    )
    assert "ix_authors_records_record_id" in _get_indexes("records_authors")

    assert "ix_records_citations_cited_id" not in _get_indexes("records_citations")
    assert "ix_records_citations_cited_id_citer_id" in _get_indexes("records_citations")

    alembic.upgrade(target="5a0e2405b624")
    assert _check_column_in_table("records_citations", "is_self_citation") is True

    alembic.upgrade(target="8ba47044154a")
    assert "ix_records_citations_cited_id_citation_type" in _get_indexes(
        "records_citations"
    )
    assert "ix_records_citations_citer_id_citation_type" in _get_indexes(
        "records_citations"
    )

    alembic.upgrade(target="020b99d0beb7")
    assert "ix_records_authors_id_type_record_id" in _get_indexes("records_authors")

    alembic.upgrade(target="afe5f484abcc")

    assert "experiment_literature" in _get_table_names()

    assert "ix_experiment_literature_literature_uuid" in _get_indexes(
        "experiment_literature"
    )
    assert "ix_experiment_literature_experiment_uuid" in _get_indexes(
        "experiment_literature"
    )