20

I need to insert a new column into an existing column family via a CQL script.

I want to do something like:

alter COLUMNFAMILY rules ADD rule_template text IF NOT EXISTS;

How can I achieve this purely in CQL script?

beterthanlife
  • 1,668
  • 2
  • 18
  • 30

1 Answers1

29

There is no optional "if not exists" for altering column families (tables). As a workaround you could just execute the alter command and ignore the error if the column already exists. There shouldn't be any harm in it, other than the error message.

BrianC
  • 10,591
  • 2
  • 30
  • 50
  • 6
    Yea that works. My assumption was that an error would halt the script mid flow. I guess the lesson here is to try before you cry. – beterthanlife Sep 09 '14 at 07:34