littleK0i / SnowDDL

Declarative database change management tool for Snowflake
Apache License 2.0
104 stars 27 forks source link

Argument --env-prefix is required for destroy action in singledb () #88

Closed AntoineLesparre closed 7 months ago

AntoineLesparre commented 8 months ago

Describe the bug When trying a destroy action using snowddl-singledb, I get the following error:

ValueError: Argument --env-prefix is required for [destroy] action

The argument --env-prefix should not be required according to the documentation (https://docs.snowddl.com/single-db/overview)

Argument --destroy-without-prefix does not exist in SingleDB mode. Destroy action is allowed without prefix, since the potential damage is low and limited to a single database.

Expected behavior Destroy action should be attempted without asking for an environment prefix.

Attach log

snowddl-singledb --config-db mydb --target-db MYDB_DEV --include-object-types TABLE,VIEW,STREAM --apply-unsafe --apply-replace-table destroy
2024-03-21 16:01:02.814 - INFO - Snowflake version = 8.11.4 (STANDARD), SnowDDL version = 0.25.0
2024-03-21 16:01:02.814 - INFO - Account = XXXXX, Region = AWS_EU_WEST_3
2024-03-21 16:01:02.814 - INFO - Session = XXXX, User = XXXXX
2024-03-21 16:01:02.814 - INFO - Role = XXXXX, Warehouse = XXXXX
2024-03-21 16:01:02.814 - INFO - Roles in session = XXXXX,XXXXX,XXXXX
2024-03-21 16:01:02.814 - INFO - ---
Traceback (most recent call last):
  File "/Users/localuser/miniconda3/envs/project/bin/snowddl-singledb", line 8, in <module>
    sys.exit(entry_point())
             ^^^^^^^^^^^^^
  File "/Users/localuser/miniconda3/envs/project/lib/python3.11/site-packages/snowddl/app/singledb.py", line 257, in entry_point
    app.execute()
  File "/Users/localuser/miniconda3/envs/project/lib/python3.11/site-packages/snowddl/app/base.py", line 446, in execute
    raise ValueError("Argument --env-prefix is required for [destroy] action")
ValueError: Argument --env-prefix is required for [destroy] action
littleK0i commented 8 months ago

Thank you for pointing this out. This code drifted a little bit from its original idea.

Please try version 0.25.1. It should work according to documentation.

I'll think about creating a slightly modified implementation of "env_prefix" specifically for SingleDB in future. Something like "schema prefixes".