<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: RamsonGomes</title>
    <description>The latest articles on DEV Community by RamsonGomes (@ramsongomes).</description>
    <link>https://dev.to/ramsongomes</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F259635%2F6c0c86ac-a9d5-4d56-b307-4b8fbc54735d.png</url>
      <title>DEV Community: RamsonGomes</title>
      <link>https://dev.to/ramsongomes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ramsongomes"/>
    <language>en</language>
    <item>
      <title>Mysql 5.6: alter column to set default to current_timestamp
</title>
      <dc:creator>RamsonGomes</dc:creator>
      <pubDate>Mon, 28 Oct 2019 08:40:31 +0000</pubDate>
      <link>https://dev.to/ramsongomes/mysql-5-6-alter-column-to-set-default-to-currenttimestamp-2ga3</link>
      <guid>https://dev.to/ramsongomes/mysql-5-6-alter-column-to-set-default-to-currenttimestamp-2ga3</guid>
      <description>&lt;p&gt;This should be so simple but I'm pulling my hair out trying to figure this out.&lt;/p&gt;

&lt;p&gt;This example mimics the migrations I'll run - essentially it's add a new nullable column to the table, set the value to match another column, then default it to current_timestamp/not nullable going forward.&lt;/p&gt;

&lt;p&gt;DROP TABLE IF EXISTS testing; &lt;br&gt;
CREATE TABLE testing (id BIGINT(20), created_at DATETIME); &lt;br&gt;
ALTER TABLE testing ADD COLUMN new_column DATETIME DEFAULT NULL; &lt;br&gt;
UPDATE testing SET new_column=created_at; &lt;br&gt;
ALTER TABLE testing ALTER new_column SET DEFAULT current_timestamp; &lt;br&gt;
That very last command results in:&lt;/p&gt;

&lt;p&gt;You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'current_timestamp' at line 1&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
