Browse Source

Add modification timestamp to user metadata

rpm
J. King 3 years ago
parent
commit
5c83655541
  1. 4
      lib/Database.php
  2. 1
      sql/MySQL/6.sql
  3. 1
      sql/PostgreSQL/6.sql
  4. 1
      sql/SQLite3/6.sql

4
lib/Database.php

@ -322,8 +322,8 @@ class Database {
}
$tr = $this->begin();
$find = $this->db->prepare("SELECT count(*) from arsse_user_meta where owner = ? and \"key\" = ?", "str", "strict str");
$update = $this->db->prepare("UPDATE arsse_user_meta set value = ? where owner = ? and \"key\" = ?", "str", "str", "str");
$insert = $this->db->prepare("INSERT INTO arsse_user_meta values(?, ?, ?)", "str", "strict str", "str");
$update = $this->db->prepare("UPDATE arsse_user_meta set value = ?, modified = CURRENT_TIMESTAMP where owner = ? and \"key\" = ?", "str", "str", "str");
$insert = $this->db->prepare("INSERT INTO arsse_user_meta(owner, \"key\", value) values(?, ?, ?)", "str", "strict str", "str");
foreach ($data as $k => $v) {
if ($k === "admin") {
$this->db->prepare("UPDATE arsse_users SET admin = ? where id = ?", "bool", "str")->run($v, $user);

1
sql/MySQL/6.sql

@ -22,6 +22,7 @@ alter table arsse_users modify num bigint unsigned not null;
create table arsse_user_meta(
owner varchar(255) not null,
"key" varchar(255) not null,
modified datetime(0) not null default CURRENT_TIMESTAMP,
value longtext,
foreign key(owner) references arsse_users(id) on delete cascade on update cascade,
primary key(owner,"key")

1
sql/PostgreSQL/6.sql

@ -23,6 +23,7 @@ alter table arsse_users alter column num set not null;
create table arsse_user_meta(
owner text not null references arsse_users(id) on delete cascade on update cascade,
key text not null,
modified timestamp(0) without time zone not null default CURRENT_TIMESTAMP,
value text,
primary key(owner,key)
);

1
sql/SQLite3/6.sql

@ -34,6 +34,7 @@ create table arsse_user_meta(
-- It is up to individual applications (i.e. the client protocols) to cooperate with names and types
owner text not null references arsse_users(id) on delete cascade on update cascade, -- the user to whom the metadata belongs
key text not null, -- metadata key
modified text not null default CURRENT_TIMESTAMP, -- time at which the metadata was last changed
value text, -- metadata value
primary key(owner,key)
) without rowid;

Loading…
Cancel
Save