util.sql: Rewrite auto increment columns to SERIAL for PostgreSQL
authorKim Alvefur <zash@zash.se>
Mon, 11 Nov 2013 23:09:18 +0100
changeset 5912 f6145e894569
parent 5910 a19b3646d5f0
child 5913 6865eecaf5a5
util.sql: Rewrite auto increment columns to SERIAL for PostgreSQL
util/sql.lua
--- a/util/sql.lua	Sun Nov 10 23:10:27 2013 +0000
+++ b/util/sql.lua	Mon Nov 11 23:09:18 2013 +0100
@@ -264,13 +264,14 @@
 		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";