title: How do I alter a CHECK constraint on Firebird?
body: <p>I have a Firebird table like this:</p>
  
  <pre><code>CREATE TABLE events (
      event      VARCHAR(6)    NOT NULL
                 CHECK (event IN ('deploy', 'revert', 'fail')),
      change_id  CHAR(40)      NOT NULL,
      change     VARCHAR(512)  NOT NULL
  );
  </code></pre>
  
  <p>Now I need to add another value to the <code>IN()</code> list in the CHECK constraint. How do I do that?</p>
  
  <p>Things I've tried so far:</p>
  
  <ul>
  <li><p>Updating the value in <code>RDB$TRIGGERS.RDB$TRIGGER_SOURCE</code>:</p>
  
  <pre><code>UPDATE RDB$TRIGGERS
     SET RDB$TRIGGER_SOURCE = 'CHECK (event IN (''deploy'', ''revert'', ''fail'', ''merge''))'
   WHERE RDB$TRIGGER_SOURCE = 'CHECK (event IN (''deploy'', ''revert'', ''fail''))';
  </code></pre>
  
  <p>Does not seem to work, as the trigger is compiled in <code>RDB$TRIGGERS.RDB$TRIGGER_BLR</code>.</p></li>
  <li><p>Creating a new table with a new check, copying the data over, dropping the old table and renaming the new table. However, it seems that one <a href="https://stackoverflow.com/a/12293244/79202">cannot rename a Firebird table</a>, so I can't make the new table have the same name as the old one.</p></li>
  </ul>
  
  <p>I suspect updating <code>RDB$TRIGGERS</code> is the way to go (idk!), if only I could get Firebird to recompile the code. But maybe there's a better way?</p>