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
commit22be28318711e0846c9a00ef3a308119f1f3f1b1 (patch)
tree1082fc7f903f369626802fad0588fd7aae7c2b14 /util
parent136139f068145195233ed7aeb444d1a9bb45f7d4 (diff)
downloadprosody-22be28318711e0846c9a00ef3a308119f1f3f1b1.tar.gz
prosody-22be28318711e0846c9a00ef3a308119f1f3f1b1.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.. ");"