From 36e0667ed287ba52f858fff7bf1a741bb23ae6de Mon Sep 17 00:00:00 2001 From: Gent Semaj Date: Thu, 28 Nov 2024 23:01:29 -0500 Subject: [PATCH] Add Email and LastPasswordReset columns to Account table (#299) * Add Email column to Account table * Add LastPasswordReset timestamp column, missing DB version bump --- sql/migration5.sql | 8 ++++++++ sql/tables.sql | 22 ++++++++++++---------- src/db/Database.hpp | 2 +- 3 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 sql/migration5.sql diff --git a/sql/migration5.sql b/sql/migration5.sql new file mode 100644 index 0000000..5b557ee --- /dev/null +++ b/sql/migration5.sql @@ -0,0 +1,8 @@ +BEGIN TRANSACTION; +-- New Columns +ALTER TABLE Accounts ADD Email TEXT DEFAULT '' NOT NULL; +ALTER TABLE Accounts ADD LastPasswordReset INTEGER DEFAULT 0 NOT NULL; +-- Update DB Version +UPDATE Meta SET Value = 6 WHERE Key = 'DatabaseVersion'; +UPDATE Meta SET Value = strftime('%s', 'now') WHERE Key = 'LastMigration'; +COMMIT; diff --git a/sql/tables.sql b/sql/tables.sql index 70b3169..11e1650 100644 --- a/sql/tables.sql +++ b/sql/tables.sql @@ -1,14 +1,16 @@ CREATE TABLE IF NOT EXISTS Accounts ( - AccountID INTEGER NOT NULL, - Login TEXT NOT NULL UNIQUE COLLATE NOCASE, - Password TEXT NOT NULL, - Selected INTEGER DEFAULT 1 NOT NULL, - AccountLevel INTEGER NOT NULL, - Created INTEGER DEFAULT (strftime('%s', 'now')) NOT NULL, - LastLogin INTEGER DEFAULT (strftime('%s', 'now')) NOT NULL, - BannedUntil INTEGER DEFAULT 0 NOT NULL, - BannedSince INTEGER DEFAULT 0 NOT NULL, - BanReason TEXT DEFAULT '' NOT NULL, + AccountID INTEGER NOT NULL, + Login TEXT NOT NULL UNIQUE COLLATE NOCASE, + Password TEXT NOT NULL, + Selected INTEGER DEFAULT 1 NOT NULL, + AccountLevel INTEGER NOT NULL, + Created INTEGER DEFAULT (strftime('%s', 'now')) NOT NULL, + LastLogin INTEGER DEFAULT (strftime('%s', 'now')) NOT NULL, + BannedUntil INTEGER DEFAULT 0 NOT NULL, + BannedSince INTEGER DEFAULT 0 NOT NULL, + BanReason TEXT DEFAULT '' NOT NULL, + Email TEXT DEFAULT '' NOT NULL, + LastPasswordReset INTEGER DEFAULT 0 NOT NULL, PRIMARY KEY(AccountID AUTOINCREMENT) ); diff --git a/src/db/Database.hpp b/src/db/Database.hpp index 151d595..57bc3bf 100644 --- a/src/db/Database.hpp +++ b/src/db/Database.hpp @@ -5,7 +5,7 @@ #include #include -#define DATABASE_VERSION 5 +#define DATABASE_VERSION 6 namespace Database {