Skip to content

Error during initial deploy when dry-run and create-change-history-table set to true #326

@chris-gonzalez-321

Description

@chris-gonzalez-321

Describe the bug

Hello,

This is the error in question:

File "/opt/hostedtoolcache/Python/3.13.2/x64/lib/python3.13/site-packages/schemachange/cli.py", line 71, in main
    deploy(config=config, session=session)
    ~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.13.2/x64/lib/python3.13/site-packages/schemachange/deploy.py", line 102, in deploy
    script_metadata = versioned_scripts.get(script.name)
                      ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get'

I took a quick peek at the code. It looks like if dry-run and create-change-history-table are both set to true, with CHANGE_HISTORY table not yet created, the code errors when attempting to find a versioned script entry in a dictionary set to None.

To Reproduce

Run schemachange command and make sure:

  1. dry-run is set to true
  2. create-change-history-table is set to true
  3. CHANGE_HISTORY table does not yet exist

Expected behavior

This was caught because of how we have our pipeline set up - where a dry-run deploy runs first, then the true deploy after manual approval.

If an initial "true" deploy should be done prior to doing the dry-run, then the documentation should probably include a disclaimer for dry-run option (unless I missed it).

Otherwise, I'm thinking the fix would be:

Return an empty dictionary for already-applied versioned scripts only if:

  1. dry-run is set to true
  2. create-change-history-table is set to true
  3. CHANGE_HISTORY table does not yet exist

Schemachange

  • Version: 4.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions