[odrs-web/production] Use non-backwards compat table names for the migration
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [odrs-web/production] Use non-backwards compat table names for the migration
- Date: Mon, 26 Sep 2016 09:46:50 +0000 (UTC)
commit 74d5d326b62eb2c16498a77a721ed86399bf131a
Author: Richard Hughes <richard hughsie com>
Date: Mon Sep 26 09:55:06 2016 +0100
Use non-backwards compat table names for the migration
README.md | 12 ++++++------
database.py | 22 +++++++++++-----------
2 files changed, 17 insertions(+), 17 deletions(-)
---
diff --git a/README.md b/README.md
index 59148ea..dfdd9a5 100644
--- a/README.md
+++ b/README.md
@@ -37,7 +37,7 @@ To set up the database tables do:
review_id INT DEFAULT 0,
UNIQUE KEY id (vote_id)
) CHARSET=utf8;
- CREATE TABLE users2 (
+ CREATE TABLE users (
user_id INT NOT NULL AUTO_INCREMENT,
date_created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
user_hash TEXT DEFAULT NULL,
@@ -46,7 +46,7 @@ To set up the database tables do:
password TEXT DEFAULT NULL,
UNIQUE KEY id (user_id)
) CHARSET=utf8;
- CREATE TABLE eventlog2 (
+ CREATE TABLE eventlog (
eventlog_id INT NOT NULL AUTO_INCREMENT,
date_created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
user_addr TEXT DEFAULT NULL,
@@ -62,7 +62,7 @@ To set up the database tables do:
fetch_cnt INT DEFAULT 1,
UNIQUE (datestr,app_id)
) CHARSET=utf8;
- CREATE INDEX date_created_idx ON eventlog2 (date_created);
+ CREATE INDEX date_created_idx ON eventlog (date_created);
## How do I backup the data ##
@@ -114,9 +114,9 @@ Then restore the data with:
## Can I clean up the event log a bit? ##
mysql
- DELETE FROM eventlog2 WHERE message = 'already reviewed';
- DELETE FROM eventlog2 WHERE message = 'duplicate vote';
- DELETE FROM eventlog2 WHERE message = 'getting';
+ DELETE FROM eventlog WHERE message = 'already reviewed';
+ DELETE FROM eventlog WHERE message = 'duplicate vote';
+ DELETE FROM eventlog WHERE message = 'getting';
## How to I use distro packages ##
diff --git a/database.py b/database.py
index 38e435e..9bbcdb9 100644
--- a/database.py
+++ b/database.py
@@ -274,7 +274,7 @@ class ReviewsDatabase(object):
""" Adds a warning to the event log """
try:
cur = self._db.cursor()
- cur.execute("INSERT INTO eventlog2 (user_addr, user_hash, app_id, "
+ cur.execute("INSERT INTO eventlog (user_addr, user_hash, app_id, "
"message, important) "
"VALUES (%s, %s, %s, %s, %s);",
(user_addr, user_hash, app_id, message, important,))
@@ -302,7 +302,7 @@ class ReviewsDatabase(object):
""" Add a user to the database """
try:
cur = self._db.cursor()
- cur.execute("INSERT INTO users2 (user_hash) VALUES (%s);",
+ cur.execute("INSERT INTO users (user_hash) VALUES (%s);",
(user_hash,))
except mdb.Error as e:
raise CursorError(cur, e)
@@ -313,7 +313,7 @@ class ReviewsDatabase(object):
cur = self._db.cursor()
cur.execute("SELECT user_id, date_created, "
"user_hash, karma, is_banned "
- "FROM users2 ORDER BY user_id DESC;")
+ "FROM users ORDER BY user_id DESC;")
except mdb.Error as e:
raise CursorError(cur, e)
res = cur.fetchall()
@@ -330,7 +330,7 @@ class ReviewsDatabase(object):
cur = self._db.cursor()
cur.execute("SELECT user_id, date_created, "
"user_hash, karma, is_banned "
- "FROM users2 WHERE user_hash=%s and password=%s;",
+ "FROM users WHERE user_hash=%s and password=%s;",
(username,
_password_hash(password),))
except mdb.Error as e:
@@ -346,7 +346,7 @@ class ReviewsDatabase(object):
cur = self._db.cursor()
cur.execute("SELECT user_id, date_created, "
"user_hash, karma, is_banned "
- "FROM users2 WHERE user_id=%s;",
+ "FROM users WHERE user_id=%s;",
(user_hash,))
except mdb.Error as e:
raise CursorError(cur, e)
@@ -361,7 +361,7 @@ class ReviewsDatabase(object):
cur = self._db.cursor()
cur.execute("SELECT user_id, date_created, "
"user_hash, karma, is_banned "
- "FROM users2 WHERE user_hash=%s ORDER BY user_id DESC;",
+ "FROM users WHERE user_hash=%s ORDER BY user_id DESC;",
(user_hash,))
except mdb.Error as e:
raise CursorError(cur, e)
@@ -376,11 +376,11 @@ class ReviewsDatabase(object):
cur = self._db.cursor()
if best:
cur.execute("SELECT user_id, date_created, "
- "user_hash, karma, is_banned FROM users2 "
+ "user_hash, karma, is_banned FROM users "
"WHERE karma != 0 ORDER BY karma DESC LIMIT 10;")
else:
cur.execute("SELECT user_id, date_created, "
- "user_hash, karma, is_banned FROM users2 "
+ "user_hash, karma, is_banned FROM users "
"WHERE karma != 0 ORDER BY karma ASC LIMIT 10;")
except mdb.Error as e:
raise CursorError(cur, e)
@@ -402,7 +402,7 @@ class ReviewsDatabase(object):
# update the karma value
try:
cur = self._db.cursor()
- cur.execute("UPDATE users2 SET karma = karma + %s "
+ cur.execute("UPDATE users SET karma = karma + %s "
"WHERE user_hash = %s;", (val, user_hash,))
except mdb.Error as e:
raise CursorError(cur, e)
@@ -457,7 +457,7 @@ class ReviewsDatabase(object):
try:
cur = self._db.cursor()
cur.execute("SELECT DISTINCT app_id, COUNT(app_id) as total "
- "FROM eventlog2 WHERE app_id IS NOT NULL "
+ "FROM eventlog WHERE app_id IS NOT NULL "
"AND message=%s GROUP BY app_id "
"ORDER BY total DESC LIMIT %s;",
(msg, limit,))
@@ -581,7 +581,7 @@ class ReviewsDatabase(object):
start = now - datetime.timedelta((i * interval) + interval - 1)
end = now - datetime.timedelta((i * interval) - 1)
try:
- cur.execute("SELECT COUNT(*) FROM eventlog2 "
+ cur.execute("SELECT COUNT(*) FROM eventlog "
"WHERE message = %s AND date_created BETWEEN %s "
"AND %s", (msg, start, end,))
except mdb.Error as e:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]