aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2013-10-28 23:20:25 +0100
committerKim Alvefur <zash@zash.se>2013-10-28 23:20:25 +0100
commit4c4a45a987e4687deba06719036b72966a6085ac (patch)
tree1082fc7f903f369626802fad0588fd7aae7c2b14 /util
parent50ec28d155b199d8fd801926e1c5a136c929f7ce (diff)
downloadprosody-4c4a45a987e4687deba06719036b72966a6085ac.tar.gz
prosody-4c4a45a987e4687deba06719036b72966a6085ac.zip
util.sql: Support incrementing columns
Diffstat (limited to 'util')
-rw-r--r--util/sql.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/util/sql.lua b/util/sql.lua
index 7c9743e1..cab1bcec 100644
--- a/util/sql.lua
+++ b/util/sql.lua
@@ -263,6 +263,15 @@ function engine:_create_table(table)
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.. ");"