# HG changeset patch # User Kim Alvefur # Date 1382998825 -3600 # Node ID 1f860279b2f839af1280c22eb5e80222eee90914 # Parent 1237f9cc312302a234abedc3c34375af37c5aefb util.sql: Support incrementing columns diff -r 1237f9cc3123 -r 1f860279b2f8 util/sql.lua --- a/util/sql.lua Mon Oct 28 23:19:47 2013 +0100 +++ b/util/sql.lua Mon Oct 28 23:20:25 2013 +0100 @@ -263,6 +263,15 @@ sql = sql.."`"..col.name.."` "..col.type; if col.nullable == false then sql = sql.." NOT NULL"; end if col.primary_key == true then sql = sql.." PRIMARY KEY"; end + if col.auto_increment == true then + if self.params.driver == "PostgreSQL" then + sql = sql.." SERIAL"; + elseif self.params.driver == "MySQL" then + sql = sql.." AUTO_INCREMENT"; + elseif self.params.driver == "SQLite3" then + sql = sql.." AUTOINCREMENT"; + end + end if i ~= #table.c then sql = sql..", "; end end sql = sql.. ");"