summaryrefslogtreecommitdiff
path: root/schemas
diff options
context:
space:
mode:
authorFrédéric Guillot <fguillot@users.noreply.github.com>2014-04-19 22:12:12 -0400
committerFrédéric Guillot <fguillot@users.noreply.github.com>2014-04-19 22:12:12 -0400
commita04ecbde778decfdea7200806a6b1144861ae05f (patch)
treee4670e3013734d9c7bd201f5d6ef1fbaae13d3b5 /schemas
parent5aacb6a76351889a6ec5ed01c8e80f139c2b2027 (diff)
Add RememberMe feature and authentications history
Diffstat (limited to 'schemas')
-rw-r--r--schemas/mysql.php32
-rw-r--r--schemas/sqlite.php31
2 files changed, 63 insertions, 0 deletions
diff --git a/schemas/mysql.php b/schemas/mysql.php
index cdd497e3..245232bd 100644
--- a/schemas/mysql.php
+++ b/schemas/mysql.php
@@ -2,6 +2,38 @@
namespace Schema;
+function version_12($pdo)
+{
+ $pdo->exec("
+ CREATE TABLE remember_me (
+ id INT NOT NULL AUTO_INCREMENT,
+ user_id INT,
+ ip VARCHAR(40),
+ user_agent VARCHAR(255),
+ token VARCHAR(255),
+ sequence VARCHAR(255),
+ expiration INT,
+ date_creation INT,
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
+ PRIMARY KEY (id)
+ ) ENGINE=InnoDB CHARSET=utf8"
+ );
+
+ $pdo->exec("
+ CREATE TABLE last_logins (
+ id INT NOT NULL AUTO_INCREMENT,
+ auth_type VARCHAR(25),
+ user_id INT,
+ ip VARCHAR(40),
+ user_agent VARCHAR(255),
+ date_creation INT,
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
+ PRIMARY KEY (id),
+ INDEX (user_id)
+ ) ENGINE=InnoDB CHARSET=utf8"
+ );
+}
+
function version_11($pdo)
{
}
diff --git a/schemas/sqlite.php b/schemas/sqlite.php
index 26ae09f7..4a69751c 100644
--- a/schemas/sqlite.php
+++ b/schemas/sqlite.php
@@ -2,6 +2,37 @@
namespace Schema;
+function version_12($pdo)
+{
+ $pdo->exec(
+ 'CREATE TABLE remember_me (
+ id INTEGER PRIMARY KEY,
+ user_id INTEGER,
+ ip TEXT,
+ user_agent TEXT,
+ token TEXT,
+ sequence TEXT,
+ expiration INTEGER,
+ date_creation INTEGER,
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
+ )'
+ );
+
+ $pdo->exec(
+ 'CREATE TABLE last_logins (
+ id INTEGER PRIMARY KEY,
+ auth_type TEXT,
+ user_id INTEGER,
+ ip TEXT,
+ user_agent TEXT,
+ date_creation INTEGER,
+ FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
+ )'
+ );
+
+ $pdo->exec('CREATE INDEX last_logins_user_idx ON last_logins(user_id)');
+}
+
function version_11($pdo)
{
$pdo->exec(