1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 21:22:40 +00:00

Hopefully complete MySQL schema

This commit is contained in:
J. King 2018-12-15 11:09:46 -05:00
parent 86c16d3cb3
commit 316ba941a2
4 changed files with 47 additions and 14 deletions

View file

@ -7,7 +7,7 @@
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;
create table arsse_users( create table arsse_users(
id varchar(255) primary key, id varchar(255) primary key,
@ -17,14 +17,14 @@ create table arsse_users(
avatar_data longblob, avatar_data longblob,
admin boolean default 0, admin boolean default 0,
rights bigint not null default 0 rights bigint not null default 0
); ) character set utf8mb4;
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;
create table arsse_folders( create table arsse_folders(
id serial primary key, id serial primary key,
@ -33,7 +33,7 @@ create table arsse_folders(
name varchar(255) not null, name varchar(255) not null,
modified datetime(0) not null default CURRENT_TIMESTAMP, -- modified datetime(0) not null default CURRENT_TIMESTAMP, --
unique(owner,name,parent) unique(owner,name,parent)
); ) character set utf8mb4;
create table arsse_feeds( create table arsse_feeds(
id serial primary key, id serial primary key,
@ -53,7 +53,7 @@ create table arsse_feeds(
size bigint not null default 0, size bigint not null default 0,
scrape boolean not null default 0, scrape boolean not null default 0,
unique(url,username,password) unique(url,username,password)
); ) character set utf8mb4;
create table arsse_subscriptions( create table arsse_subscriptions(
id serial primary key, id serial primary key,
@ -66,7 +66,7 @@ create table arsse_subscriptions(
pinned boolean not null default 0, pinned boolean not null default 0,
folder bigint references arsse_folders(id) on delete cascade, folder bigint references arsse_folders(id) on delete cascade,
unique(owner,feed) unique(owner,feed)
); ) character set utf8mb4;
create table arsse_articles( create table arsse_articles(
id serial primary key, id serial primary key,
@ -82,13 +82,13 @@ create table arsse_articles(
url_title_hash varchar(255) not null, url_title_hash varchar(255) not null,
url_content_hash varchar(255) not null, url_content_hash varchar(255) not null,
title_content_hash varchar(255) not null title_content_hash varchar(255) not null
); ) character set utf8mb4;
create table arsse_enclosures( create table arsse_enclosures(
article bigint not null references arsse_articles(id) on delete cascade, article bigint not null references arsse_articles(id) on delete cascade,
url varchar(255), url varchar(255),
type varchar(255) type varchar(255)
); ) character set utf8mb4;
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,
@ -97,17 +97,17 @@ create table arsse_marks(
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)
); ) character set utf8mb4;
create table arsse_editions( create table arsse_editions(
id serial primary key, id serial primary key,
article bigint not null references arsse_articles(id) on delete cascade, article bigint not null references arsse_articles(id) on delete cascade,
modified datetime(0) not null default CURRENT_TIMESTAMP modified datetime(0) not null default CURRENT_TIMESTAMP
); ) character set utf8mb4;
create table arsse_categories( create table arsse_categories(
article bigint not null references arsse_articles(id) on delete cascade, article bigint not null references arsse_articles(id) on delete cascade,
name varchar(255) name varchar(255)
); ) character set utf8mb4;
insert into arsse_meta(`key`,value) values('schema_version','1'); insert into arsse_meta(`key`,value) values('schema_version','1');

View file

@ -9,7 +9,7 @@ create table arsse_sessions (
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;
create table arsse_labels ( create table arsse_labels (
id serial primary key, id serial primary key,
@ -17,7 +17,7 @@ create table arsse_labels (
name varchar(255) not null, name varchar(255) not null,
modified datetime(0) not null default CURRENT_TIMESTAMP, modified datetime(0) not null default CURRENT_TIMESTAMP,
unique(owner,name) unique(owner,name)
); ) character set utf8mb4;
create table arsse_label_members ( create table arsse_label_members (
label bigint not null references arsse_labels(id) on delete cascade, label bigint not null references arsse_labels(id) on delete cascade,
@ -26,7 +26,7 @@ create table arsse_label_members (
assigned boolean not null default 1, assigned boolean not null default 1,
modified datetime(0) not null default CURRENT_TIMESTAMP, modified datetime(0) not null default CURRENT_TIMESTAMP,
primary key(label,article) primary key(label,article)
); ) character set utf8mb4;
alter table arsse_marks add column note longtext not null default ''; alter table arsse_marks add column note longtext not null default '';

23
sql/MySQL/2.sql Normal file
View 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
alter table arsse_users default character set utf8mb4 collate utf8mb4_unicode_nopad_ci;
alter table arsse_folders default character set utf8mb4 collate utf8mb4_unicode_nopad_ci;
alter table arsse_feeds default character set utf8mb4 collate utf8mb4_unicode_nopad_ci;
alter table arsse_subscriptions default character set utf8mb4 collate utf8mb4_unicode_nopad_ci;
alter table arsse_articles default character set utf8mb4 collate utf8mb4_unicode_nopad_ci;
alter table arsse_categories default character set utf8mb4 collate utf8mb4_unicode_nopad_ci;
alter table arsse_labels default character set utf8mb4 collate utf8mb4_unicode_nopad_ci;
alter table arsse_users convert to character set utf8mb4 collate utf8mb4_unicode_nopad_ci;
alter table arsse_folders convert to character set utf8mb4 collate utf8mb4_unicode_nopad_ci;
alter table arsse_feeds convert to character set utf8mb4 collate utf8mb4_unicode_nopad_ci;
alter table arsse_subscriptions convert to character set utf8mb4 collate utf8mb4_unicode_nopad_ci;
alter table arsse_articles convert to character set utf8mb4 collate utf8mb4_unicode_nopad_ci;
alter table arsse_categories convert to character set utf8mb4 collate utf8mb4_unicode_nopad_ci;
alter table arsse_labels convert to character set utf8mb4 collate utf8mb4_unicode_nopad_ci;
update arsse_meta set value = '3' where `key` = 'schema_version';

10
sql/MySQL/3.sql Normal file
View file

@ -0,0 +1,10 @@
-- 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
alter table arsse_marks change column modified modified datetime(0);
alter table arsse_marks add column touched boolean not null default 0;
update arsse_meta set value = '4' where `key` = 'schema_version';