From fe88e363aa93e4593a5e488e1bfd76d4d0e7481c Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Fri, 9 Dec 2016 18:41:42 +1000 Subject: [PATCH] Updated users_sql_update.pl to include bwavepktno --- users.c | 2 +- utils/sql_update/users_sql_update.pl | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/users.c b/users.c index 8265969..92d49f4 100644 --- a/users.c +++ b/users.c @@ -190,7 +190,7 @@ int inst_user(struct user_record *user) { if (rc == SQLITE_OK) { sqlite3_bind_text(res, 1, user->loginname, -1, 0); sqlite3_bind_text(res, 2, user->password, -1, 0); - sqlite3_bind_text(res, 3, user->salt, -1, 0); + sqlite3_bind_text(res, 3, user->salt, -1, 0); sqlite3_bind_text(res, 4, user->firstname, -1, 0); sqlite3_bind_text(res, 5, user->lastname, -1, 0); sqlite3_bind_text(res, 6, user->email, -1, 0); diff --git a/utils/sql_update/users_sql_update.pl b/utils/sql_update/users_sql_update.pl index 2dabe48..fa95c1d 100755 --- a/utils/sql_update/users_sql_update.pl +++ b/utils/sql_update/users_sql_update.pl @@ -76,3 +76,24 @@ if (check_exists("archiver") == 0) { $dbh->do($sql); $dbh->disconnect; } + +if (check_exists("bwavepktno") == 0) { + print "Column \"bwavepktno\" doesn't exist... adding..\n"; + + my ($needed) = @_; + + my $dsn = "dbi:SQLite:dbname=$dbfile"; + my $user = ""; + my $password = ""; + my $dbh = DBI->connect($dsn, $user, $password, { + PrintError => 0, + RaiseError => 1, + AutoCommit => 1, + FetchHashKeyName => 'NAME_lc', + }); + + my $sql = "ALTER TABLE users ADD COLUMN bwavepktno INTEGER DEFAULT 0"; + $dbh->do($sql); + $dbh->disconnect; +} +