Software /
code /
prosody
Changeset
5887:1f860279b2f8
util.sql: Support incrementing columns
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 28 Oct 2013 23:20:25 +0100 |
parents | 5886:1237f9cc3123 |
children | 5888:f3e408ae59a6 |
files | util/sql.lua |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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.. ");"