From 91f87be18f6602f9b0fd793fa5600aa5dbf213e8 Mon Sep 17 00:00:00 2001 From: Mysh! Date: Tue, 21 Jul 2020 19:05:20 +0800 Subject: [PATCH] Fix Sqlite3 and Postgres indexes By adding "IF NOT EXISTS" to the "initQueries" structure we remove the case of panic, when the user does not remove the previous table. Related issue: https://github.com/gofiber/session/issues/13 --- providers/postgre/provider.go | 4 ++-- providers/sqlite3/provider.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/providers/postgre/provider.go b/providers/postgre/provider.go index c7a406f..ef863c5 100644 --- a/providers/postgre/provider.go +++ b/providers/postgre/provider.go @@ -18,8 +18,8 @@ var ( last_active BIGINT NOT NULL DEFAULT '0', expiration BIGINT NOT NULL DEFAULT '0' );`, - "CREATE INDEX last_active ON %s (last_active);", - "CREATE INDEX expiration ON %s (expiration);", + "CREATE INDEX IF NOT EXISTS last_active ON %s (last_active);", + "CREATE INDEX IF NOT EXISTS expiration ON %s (expiration);", } ) diff --git a/providers/sqlite3/provider.go b/providers/sqlite3/provider.go index c1fe335..c3ba462 100644 --- a/providers/sqlite3/provider.go +++ b/providers/sqlite3/provider.go @@ -18,8 +18,8 @@ var ( last_active BIGINT NOT NULL DEFAULT '0', expiration BIGINT NOT NULL DEFAULT '0' );`, - "CREATE INDEX last_active ON %s (last_active);", - "CREATE INDEX expiration ON %s (expiration);", + "CREATE INDEX IF NOT EXISTS last_active ON %s (last_active);", + "CREATE INDEX IF NOT EXISTS expiration ON %s (expiration);", } )