From 316ba941a243973fff0b486bbd47fc06df032e8b Mon Sep 17 00:00:00 2001 From: "J. King" Date: Sat, 15 Dec 2018 11:09:46 -0500 Subject: [PATCH] Hopefully complete MySQL schema --- sql/MySQL/0.sql | 22 +++++++++++----------- sql/MySQL/1.sql | 6 +++--- sql/MySQL/2.sql | 23 +++++++++++++++++++++++ sql/MySQL/3.sql | 10 ++++++++++ 4 files changed, 47 insertions(+), 14 deletions(-) create mode 100644 sql/MySQL/2.sql create mode 100644 sql/MySQL/3.sql diff --git a/sql/MySQL/0.sql b/sql/MySQL/0.sql index 2dd2003c..f6b00e26 100644 --- a/sql/MySQL/0.sql +++ b/sql/MySQL/0.sql @@ -7,7 +7,7 @@ create table arsse_meta( `key` varchar(255) primary key, value longtext -); +) character set utf8mb4; create table arsse_users( id varchar(255) primary key, @@ -17,14 +17,14 @@ create table arsse_users( avatar_data longblob, admin boolean default 0, rights bigint not null default 0 -); +) character set utf8mb4; create table arsse_users_meta( owner varchar(255) not null references arsse_users(id) on delete cascade on update cascade, `key` varchar(255) not null, value varchar(255), primary key(owner,`key`) -); +) character set utf8mb4; create table arsse_folders( id serial primary key, @@ -33,7 +33,7 @@ create table arsse_folders( name varchar(255) not null, modified datetime(0) not null default CURRENT_TIMESTAMP, -- unique(owner,name,parent) -); +) character set utf8mb4; create table arsse_feeds( id serial primary key, @@ -53,7 +53,7 @@ create table arsse_feeds( size bigint not null default 0, scrape boolean not null default 0, unique(url,username,password) -); +) character set utf8mb4; create table arsse_subscriptions( id serial primary key, @@ -66,7 +66,7 @@ create table arsse_subscriptions( pinned boolean not null default 0, folder bigint references arsse_folders(id) on delete cascade, unique(owner,feed) -); +) character set utf8mb4; create table arsse_articles( id serial primary key, @@ -82,13 +82,13 @@ create table arsse_articles( url_title_hash varchar(255) not null, url_content_hash varchar(255) not null, title_content_hash varchar(255) not null -); +) character set utf8mb4; create table arsse_enclosures( article bigint not null references arsse_articles(id) on delete cascade, url varchar(255), type varchar(255) -); +) character set utf8mb4; create table arsse_marks( 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, modified datetime(0) not null default CURRENT_TIMESTAMP, primary key(article,subscription) -); +) character set utf8mb4; create table arsse_editions( id serial primary key, article bigint not null references arsse_articles(id) on delete cascade, modified datetime(0) not null default CURRENT_TIMESTAMP -); +) character set utf8mb4; create table arsse_categories( article bigint not null references arsse_articles(id) on delete cascade, name varchar(255) -); +) character set utf8mb4; insert into arsse_meta(`key`,value) values('schema_version','1'); diff --git a/sql/MySQL/1.sql b/sql/MySQL/1.sql index aa196ca3..14e780ba 100644 --- a/sql/MySQL/1.sql +++ b/sql/MySQL/1.sql @@ -9,7 +9,7 @@ create table arsse_sessions ( created datetime(0) not null default CURRENT_TIMESTAMP, expires datetime(0) not null, `user` varchar(255) not null references arsse_users(id) on delete cascade on update cascade -); +) character set utf8mb4; create table arsse_labels ( id serial primary key, @@ -17,7 +17,7 @@ create table arsse_labels ( name varchar(255) not null, modified datetime(0) not null default CURRENT_TIMESTAMP, unique(owner,name) -); +) character set utf8mb4; create table arsse_label_members ( 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, modified datetime(0) not null default CURRENT_TIMESTAMP, primary key(label,article) -); +) character set utf8mb4; alter table arsse_marks add column note longtext not null default ''; diff --git a/sql/MySQL/2.sql b/sql/MySQL/2.sql new file mode 100644 index 00000000..d5a1a93c --- /dev/null +++ b/sql/MySQL/2.sql @@ -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'; diff --git a/sql/MySQL/3.sql b/sql/MySQL/3.sql new file mode 100644 index 00000000..c02df032 --- /dev/null +++ b/sql/MySQL/3.sql @@ -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';