title: How do I set a default value for a UUID primary key column in Postgres?
body: <p>I'm using PostgreSQL.  I'm trying to create a primary key column taht is a UUID, so I ran this statement</p>
  
  <pre><code>ALTER TABLE my_object_times ADD PRIMARY KEY (id) DEFAULT uuid_generate_v4();
  </code></pre>
  
  <p>but I get the error</p>
  
  <pre><code>PG::SyntaxError: ERROR:  syntax error at or near "DEFAULT"
  </code></pre>
  
  <p>What is the proper way to write the above statement (I'm doing alter because I'm changing an existing primary key column)?</p>