diff options
author | Kim Alvefur <zash@zash.se> | 2013-10-28 23:20:25 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2013-10-28 23:20:25 +0100 |
commit | 4c4a45a987e4687deba06719036b72966a6085ac (patch) | |
tree | 1082fc7f903f369626802fad0588fd7aae7c2b14 | |
parent | 50ec28d155b199d8fd801926e1c5a136c929f7ce (diff) | |
download | prosody-4c4a45a987e4687deba06719036b72966a6085ac.tar.gz prosody-4c4a45a987e4687deba06719036b72966a6085ac.zip |
util.sql: Support incrementing columns
-rw-r--r-- | util/sql.lua | 9 |
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.. ");" |