From 95457cb25bd866e3e06cc4cf1116e8408f62b744 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 11 Nov 2013 23:09:18 +0100 Subject: util.sql: Rewrite auto increment columns to SERIAL for PostgreSQL --- util/sql.lua | 7 ++++--- 1 file 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"; -- cgit v1.2.3 From b8218da015567c95dbc958d4d3885cf3ccb36050 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 11 Nov 2013 23:15:26 +0100 Subject: mod_storage_sql2: Auto increment columns won't be NULL, so drop nullable=false --- plugins/mod_storage_sql2.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/mod_storage_sql2.lua b/plugins/mod_storage_sql2.lua index 824ab859..e03b1fd6 100644 --- a/plugins/mod_storage_sql2.lua +++ b/plugins/mod_storage_sql2.lua @@ -44,7 +44,7 @@ local function create_table() local ProsodyArchiveTable = Table { name="prosodyarchive"; - Column { name="sort_id", type="INTEGER", primary_key=true, auto_increment=true, nullable=false }; + Column { name="sort_id", type="INTEGER", primary_key=true, auto_increment=true }; Column { name="host", type="TEXT", nullable=false }; Column { name="user", type="TEXT", nullable=false }; Column { name="store", type="TEXT", nullable=false }; -- cgit v1.2.3