mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 13:12:41 +00:00
Database schema for subscription tags
This commit is contained in:
parent
5efef2c2d0
commit
fb1bdbfb37
16 changed files with 90 additions and 19 deletions
|
@ -37,7 +37,7 @@ use JKingWeb\Arsse\Misc\ValueInfo;
|
||||||
*/
|
*/
|
||||||
class Database {
|
class Database {
|
||||||
/** The version number of the latest schema the interface is aware of */
|
/** The version number of the latest schema the interface is aware of */
|
||||||
const SCHEMA_VERSION = 4;
|
const SCHEMA_VERSION = 5;
|
||||||
/** The size of a set of values beyond which the set will be embedded into the query text */
|
/** The size of a set of values beyond which the set will be embedded into the query text */
|
||||||
const LIMIT_SET_SIZE = 25;
|
const LIMIT_SET_SIZE = 25;
|
||||||
/** The length of a string in an embedded set beyond which a parameter placeholder will be used for the string */
|
/** The length of a string in an embedded set beyond which a parameter placeholder will be used for the string */
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
-- Please consult the SQLite 3 schemata for commented version
|
-- Please consult the SQLite 3 schemata for commented version
|
||||||
|
|
||||||
create table arsse_meta(
|
create table arsse_meta(
|
||||||
`key` varchar(255) primary key,
|
"key" varchar(255) primary key,
|
||||||
value longtext
|
value longtext
|
||||||
) character set utf8mb4;
|
) character set utf8mb4;
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ create table arsse_users(
|
||||||
|
|
||||||
create table arsse_users_meta(
|
create table arsse_users_meta(
|
||||||
owner varchar(255) not null references arsse_users(id) on delete cascade on update cascade,
|
owner varchar(255) not null references arsse_users(id) on delete cascade on update cascade,
|
||||||
`key` varchar(255) not null,
|
"key" varchar(255) not null,
|
||||||
value varchar(255),
|
value varchar(255),
|
||||||
primary key(owner,`key`)
|
primary key(owner,"key")
|
||||||
) character set utf8mb4;
|
) character set utf8mb4;
|
||||||
|
|
||||||
create table arsse_folders(
|
create table arsse_folders(
|
||||||
|
@ -93,7 +93,7 @@ create table arsse_enclosures(
|
||||||
create table arsse_marks(
|
create table arsse_marks(
|
||||||
article bigint not null references arsse_articles(id) on delete cascade,
|
article bigint not null references arsse_articles(id) on delete cascade,
|
||||||
subscription bigint not null references arsse_subscriptions(id) on delete cascade on update cascade,
|
subscription bigint not null references arsse_subscriptions(id) on delete cascade on update cascade,
|
||||||
`read` boolean not null default 0,
|
"read" boolean not null default 0,
|
||||||
starred boolean not null default 0,
|
starred boolean not null default 0,
|
||||||
modified datetime(0) not null default CURRENT_TIMESTAMP,
|
modified datetime(0) not null default CURRENT_TIMESTAMP,
|
||||||
primary key(article,subscription)
|
primary key(article,subscription)
|
||||||
|
@ -110,4 +110,4 @@ create table arsse_categories(
|
||||||
name varchar(255)
|
name varchar(255)
|
||||||
) character set utf8mb4;
|
) character set utf8mb4;
|
||||||
|
|
||||||
insert into arsse_meta(`key`,value) values('schema_version','1');
|
insert into arsse_meta("key",value) values('schema_version','1');
|
||||||
|
|
|
@ -8,7 +8,7 @@ create table arsse_sessions (
|
||||||
id varchar(255) primary key,
|
id varchar(255) primary key,
|
||||||
created datetime(0) not null default CURRENT_TIMESTAMP,
|
created datetime(0) not null default CURRENT_TIMESTAMP,
|
||||||
expires datetime(0) not null,
|
expires datetime(0) not null,
|
||||||
`user` varchar(255) not null references arsse_users(id) on delete cascade on update cascade
|
"user" varchar(255) not null references arsse_users(id) on delete cascade on update cascade
|
||||||
) character set utf8mb4;
|
) character set utf8mb4;
|
||||||
|
|
||||||
create table arsse_labels (
|
create table arsse_labels (
|
||||||
|
@ -30,4 +30,4 @@ create table arsse_label_members (
|
||||||
|
|
||||||
alter table arsse_marks add column note longtext;
|
alter table arsse_marks add column note longtext;
|
||||||
|
|
||||||
update arsse_meta set value = '2' where `key` = 'schema_version';
|
update arsse_meta set value = '2' where "key" = 'schema_version';
|
||||||
|
|
|
@ -20,4 +20,4 @@ alter table arsse_articles convert to character set utf8mb4 collate utf8mb4_unic
|
||||||
alter table arsse_categories convert to character set utf8mb4 collate utf8mb4_unicode_ci;
|
alter table arsse_categories convert to character set utf8mb4 collate utf8mb4_unicode_ci;
|
||||||
alter table arsse_labels convert to character set utf8mb4 collate utf8mb4_unicode_ci;
|
alter table arsse_labels convert to character set utf8mb4 collate utf8mb4_unicode_ci;
|
||||||
|
|
||||||
update arsse_meta set value = '3' where `key` = 'schema_version';
|
update arsse_meta set value = '3' where "key" = 'schema_version';
|
||||||
|
|
|
@ -7,4 +7,4 @@
|
||||||
alter table arsse_marks change column modified modified datetime(0);
|
alter table arsse_marks change column modified modified datetime(0);
|
||||||
alter table arsse_marks add column touched boolean not null default 0;
|
alter table arsse_marks add column touched boolean not null default 0;
|
||||||
|
|
||||||
update arsse_meta set value = '4' where `key` = 'schema_version';
|
update arsse_meta set value = '4' where "key" = 'schema_version';
|
||||||
|
|
23
sql/MySQL/4.sql
Normal file
23
sql/MySQL/4.sql
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
-- SPDX-License-Identifier: MIT
|
||||||
|
-- Copyright 2017 J. King, Dustin Wilson et al.
|
||||||
|
-- See LICENSE and AUTHORS files for details
|
||||||
|
|
||||||
|
-- Please consult the SQLite 3 schemata for commented version
|
||||||
|
|
||||||
|
create table arsse_tags(
|
||||||
|
id serial primary key,
|
||||||
|
owner varchar(255) not null references arsse_users(id) on delete cascade on update cascade,
|
||||||
|
name varchar(255) not null,
|
||||||
|
modified datetime(0) not null default CURRENT_TIMESTAMP,
|
||||||
|
unique(owner,name)
|
||||||
|
) character set utf8mb4 collate utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
create table arsse_tag_members(
|
||||||
|
tag bigint not null references arsse_tags(id) on delete cascade,
|
||||||
|
subscription bigint not null references arsse_subscriptions(id) on delete cascade,
|
||||||
|
assigned boolean not null default 1,
|
||||||
|
modified datetime(0) not null default CURRENT_TIMESTAMP,
|
||||||
|
primary key(tag,subscription)
|
||||||
|
) character set utf8mb4 collate utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
update arsse_meta set value = '5' where "key" = 'schema_version';
|
|
@ -110,4 +110,4 @@ create table arsse_categories(
|
||||||
name text
|
name text
|
||||||
);
|
);
|
||||||
|
|
||||||
insert into arsse_meta(key,value) values('schema_version','1');
|
insert into arsse_meta("key",value) values('schema_version','1');
|
||||||
|
|
|
@ -30,4 +30,4 @@ create table arsse_label_members (
|
||||||
|
|
||||||
alter table arsse_marks add column note text not null default '';
|
alter table arsse_marks add column note text not null default '';
|
||||||
|
|
||||||
update arsse_meta set value = '2' where key = 'schema_version';
|
update arsse_meta set value = '2' where "key" = 'schema_version';
|
||||||
|
|
|
@ -13,4 +13,4 @@ alter table arsse_articles alter column author type text collate "und-x-icu";
|
||||||
alter table arsse_categories alter column name type text collate "und-x-icu";
|
alter table arsse_categories alter column name type text collate "und-x-icu";
|
||||||
alter table arsse_labels alter column name type text collate "und-x-icu";
|
alter table arsse_labels alter column name type text collate "und-x-icu";
|
||||||
|
|
||||||
update arsse_meta set value = '3' where key = 'schema_version';
|
update arsse_meta set value = '3' where "key" = 'schema_version';
|
||||||
|
|
|
@ -8,4 +8,4 @@ alter table arsse_marks alter column modified drop default;
|
||||||
alter table arsse_marks alter column modified drop not null;
|
alter table arsse_marks alter column modified drop not null;
|
||||||
alter table arsse_marks add column touched smallint not null default 0;
|
alter table arsse_marks add column touched smallint not null default 0;
|
||||||
|
|
||||||
update arsse_meta set value = '4' where key = 'schema_version';
|
update arsse_meta set value = '4' where "key" = 'schema_version';
|
||||||
|
|
23
sql/PostgreSQL/4.sql
Normal file
23
sql/PostgreSQL/4.sql
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
-- SPDX-License-Identifier: MIT
|
||||||
|
-- Copyright 2017 J. King, Dustin Wilson et al.
|
||||||
|
-- See LICENSE and AUTHORS files for details
|
||||||
|
|
||||||
|
-- Please consult the SQLite 3 schemata for commented version
|
||||||
|
|
||||||
|
create table arsse_tags(
|
||||||
|
id bigserial primary key,
|
||||||
|
owner text not null references arsse_users(id) on delete cascade on update cascade,
|
||||||
|
name text not null collate "und-x-icu",
|
||||||
|
modified timestamp(0) without time zone not null default CURRENT_TIMESTAMP,
|
||||||
|
unique(owner,name)
|
||||||
|
);
|
||||||
|
|
||||||
|
create table arsse_tag_members(
|
||||||
|
tag bigint not null references arsse_tags(id) on delete cascade,
|
||||||
|
subscription bigint not null references arsse_subscriptions(id) on delete cascade,
|
||||||
|
assigned smallint not null default 1,
|
||||||
|
modified timestamp(0) without time zone not null default CURRENT_TIMESTAMP,
|
||||||
|
primary key(tag,subscription)
|
||||||
|
);
|
||||||
|
|
||||||
|
update arsse_meta set value = '5' where "key" = 'schema_version';
|
|
@ -130,4 +130,4 @@ create table arsse_categories(
|
||||||
|
|
||||||
-- set version marker
|
-- set version marker
|
||||||
pragma user_version = 1;
|
pragma user_version = 1;
|
||||||
insert into arsse_meta(key,value) values('schema_version','1');
|
insert into arsse_meta("key",value) values('schema_version','1');
|
||||||
|
|
|
@ -20,7 +20,7 @@ create table arsse_labels(
|
||||||
);
|
);
|
||||||
|
|
||||||
create table arsse_label_members(
|
create table arsse_label_members(
|
||||||
-- uabels assignments for articles
|
-- label assignments for articles
|
||||||
label integer not null references arsse_labels(id) on delete cascade, -- label ID associated to an article; label IDs belong to a user
|
label integer not null references arsse_labels(id) on delete cascade, -- label ID associated to an article; label IDs belong to a user
|
||||||
article integer not null references arsse_articles(id) on delete cascade, -- article associated to a label
|
article integer not null references arsse_articles(id) on delete cascade, -- article associated to a label
|
||||||
subscription integer not null references arsse_subscriptions(id) on delete cascade, -- Subscription is included so that records are deleted when a subscription is removed
|
subscription integer not null references arsse_subscriptions(id) on delete cascade, -- Subscription is included so that records are deleted when a subscription is removed
|
||||||
|
@ -48,4 +48,4 @@ alter table arsse_marks_new rename to arsse_marks;
|
||||||
|
|
||||||
-- set version marker
|
-- set version marker
|
||||||
pragma user_version = 2;
|
pragma user_version = 2;
|
||||||
update arsse_meta set value = '2' where key = 'schema_version';
|
update arsse_meta set value = '2' where "key" = 'schema_version';
|
||||||
|
|
|
@ -121,4 +121,4 @@ alter table arsse_labels_new rename to arsse_labels;
|
||||||
|
|
||||||
-- set version marker
|
-- set version marker
|
||||||
pragma user_version = 3;
|
pragma user_version = 3;
|
||||||
update arsse_meta set value = '3' where key = 'schema_version';
|
update arsse_meta set value = '3' where "key" = 'schema_version';
|
||||||
|
|
|
@ -24,4 +24,4 @@ reindex nocase;
|
||||||
|
|
||||||
-- set version marker
|
-- set version marker
|
||||||
pragma user_version = 4;
|
pragma user_version = 4;
|
||||||
update arsse_meta set value = '4' where key = 'schema_version';
|
update arsse_meta set value = '4' where "key" = 'schema_version';
|
||||||
|
|
25
sql/SQLite3/4.sql
Normal file
25
sql/SQLite3/4.sql
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
-- SPDX-License-Identifier: MIT
|
||||||
|
-- Copyright 2017 J. King, Dustin Wilson et al.
|
||||||
|
-- See LICENSE and AUTHORS files for details
|
||||||
|
|
||||||
|
create table arsse_tags(
|
||||||
|
-- user-defined subscription tags
|
||||||
|
id integer primary key, -- numeric ID
|
||||||
|
owner text not null references arsse_users(id) on delete cascade on update cascade, -- owning user
|
||||||
|
name text not null collate nocase, -- tag text
|
||||||
|
modified text not null default CURRENT_TIMESTAMP, -- time at which the tag was last modified
|
||||||
|
unique(owner,name)
|
||||||
|
);
|
||||||
|
|
||||||
|
create table arsse_tag_members(
|
||||||
|
-- tag assignments for subscriptions
|
||||||
|
tag integer not null references arsse_tags(id) on delete cascade, -- tag ID associated to a subscription
|
||||||
|
subscription integer not null references arsse_subscriptions(id) on delete cascade, -- Subscription associated to a tag
|
||||||
|
assigned boolean not null default 1, -- whether the association is current, to support soft deletion
|
||||||
|
modified text not null default CURRENT_TIMESTAMP, -- time at which the association was last made or unmade
|
||||||
|
primary key(tag,subscription) -- only one association of a given tag to a given subscription
|
||||||
|
) without rowid;
|
||||||
|
|
||||||
|
-- set version marker
|
||||||
|
pragma user_version = 5;
|
||||||
|
update arsse_meta set value = '5' where "key" = 'schema_version';
|
Loading…
Reference in a new issue