diff options
author | Kim Alvefur <zash@zash.se> | 2013-11-11 23:09:18 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2013-11-11 23:09:18 +0100 |
commit | 507cb9e056a0a0a54e041df66b2dbb24d0fc4a43 (patch) | |
tree | 96f18e80c6cdd8dda33087606526f32e5a3be271 | |
parent | 12cea7620002a3bdafcebcc321dff9cb13d0ca13 (diff) | |
download | prosody-507cb9e056a0a0a54e041df66b2dbb24d0fc4a43.tar.gz prosody-507cb9e056a0a0a54e041df66b2dbb24d0fc4a43.zip |
util.sql: Rewrite auto increment columns to SERIAL for PostgreSQL
-rw-r--r-- | util/sql.lua | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/util/sql.lua b/util/sql.lua index 07b1a4e0..a7f46421 100644 --- a/util/sql.lua +++ b/util/sql.lua @@ -264,13 +264,14 @@ function engine:_create_table(table) if col_type == "MEDIUMTEXT" and self.params.driver ~= "MySQL" then col_type = "TEXT"; -- MEDIUMTEXT is MySQL-specific end + if col.auto_increment == true and self.params.driver == "PostgreSQL" then + col_type = "BIGSERIAL"; + end 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 + if self.params.driver == "MySQL" then sql = sql.." AUTO_INCREMENT"; elseif self.params.driver == "SQLite3" then sql = sql.." AUTOINCREMENT"; |