mirror of
https://github.com/miniflux/v2.git
synced 2025-08-06 17:41:00 +00:00
Create database package (refactoring)
This commit is contained in:
parent
17054b396e
commit
cf03e0e338
30 changed files with 61 additions and 54 deletions
103
database/sql/schema_version_1.sql
Normal file
103
database/sql/schema_version_1.sql
Normal file
|
@ -0,0 +1,103 @@
|
|||
create table schema_version (
|
||||
version text not null
|
||||
);
|
||||
|
||||
create table users (
|
||||
id serial not null,
|
||||
username text not null unique,
|
||||
password text,
|
||||
is_admin bool default 'f',
|
||||
language text default 'en_US',
|
||||
timezone text default 'UTC',
|
||||
theme text default 'default',
|
||||
last_login_at timestamp with time zone,
|
||||
primary key (id)
|
||||
);
|
||||
|
||||
create table sessions (
|
||||
id serial not null,
|
||||
user_id int not null,
|
||||
token text not null unique,
|
||||
created_at timestamp with time zone default now(),
|
||||
user_agent text,
|
||||
ip text,
|
||||
primary key (id),
|
||||
unique (user_id, token),
|
||||
foreign key (user_id) references users(id) on delete cascade
|
||||
);
|
||||
|
||||
create table categories (
|
||||
id serial not null,
|
||||
user_id int not null,
|
||||
title text not null,
|
||||
primary key (id),
|
||||
unique (user_id, title),
|
||||
foreign key (user_id) references users(id) on delete cascade
|
||||
);
|
||||
|
||||
create table feeds (
|
||||
id bigserial not null,
|
||||
user_id int not null,
|
||||
category_id int not null,
|
||||
title text not null,
|
||||
feed_url text not null,
|
||||
site_url text not null,
|
||||
checked_at timestamp with time zone default now(),
|
||||
etag_header text default '',
|
||||
last_modified_header text default '',
|
||||
parsing_error_msg text default '',
|
||||
parsing_error_count int default 0,
|
||||
primary key (id),
|
||||
unique (user_id, feed_url),
|
||||
foreign key (user_id) references users(id) on delete cascade,
|
||||
foreign key (category_id) references categories(id) on delete cascade
|
||||
);
|
||||
|
||||
create type entry_status as enum('unread', 'read', 'removed');
|
||||
|
||||
create table entries (
|
||||
id bigserial not null,
|
||||
user_id int not null,
|
||||
feed_id bigint not null,
|
||||
hash text not null,
|
||||
published_at timestamp with time zone not null,
|
||||
title text not null,
|
||||
url text not null,
|
||||
author text,
|
||||
content text,
|
||||
status entry_status default 'unread',
|
||||
primary key (id),
|
||||
unique (feed_id, hash),
|
||||
foreign key (user_id) references users(id) on delete cascade,
|
||||
foreign key (feed_id) references feeds(id) on delete cascade
|
||||
);
|
||||
|
||||
create index entries_feed_idx on entries using btree(feed_id);
|
||||
|
||||
create table enclosures (
|
||||
id bigserial not null,
|
||||
user_id int not null,
|
||||
entry_id bigint not null,
|
||||
url text not null,
|
||||
size int default 0,
|
||||
mime_type text default '',
|
||||
primary key (id),
|
||||
foreign key (user_id) references users(id) on delete cascade,
|
||||
foreign key (entry_id) references entries(id) on delete cascade
|
||||
);
|
||||
|
||||
create table icons (
|
||||
id bigserial not null,
|
||||
hash text not null unique,
|
||||
mime_type text not null,
|
||||
content bytea not null,
|
||||
primary key (id)
|
||||
);
|
||||
|
||||
create table feed_icons (
|
||||
feed_id bigint not null,
|
||||
icon_id bigint not null,
|
||||
primary key(feed_id, icon_id),
|
||||
foreign key (feed_id) references feeds(id) on delete cascade,
|
||||
foreign key (icon_id) references icons(id) on delete cascade
|
||||
);
|
8
database/sql/schema_version_10.sql
Normal file
8
database/sql/schema_version_10.sql
Normal file
|
@ -0,0 +1,8 @@
|
|||
drop table tokens;
|
||||
|
||||
create table sessions (
|
||||
id text not null,
|
||||
data jsonb not null,
|
||||
created_at timestamp with time zone not null default now(),
|
||||
primary key(id)
|
||||
);
|
6
database/sql/schema_version_11.sql
Normal file
6
database/sql/schema_version_11.sql
Normal file
|
@ -0,0 +1,6 @@
|
|||
alter table integrations add column wallabag_enabled bool default 'f';
|
||||
alter table integrations add column wallabag_url text default '';
|
||||
alter table integrations add column wallabag_client_id text default '';
|
||||
alter table integrations add column wallabag_client_secret text default '';
|
||||
alter table integrations add column wallabag_username text default '';
|
||||
alter table integrations add column wallabag_password text default '';
|
1
database/sql/schema_version_12.sql
Normal file
1
database/sql/schema_version_12.sql
Normal file
|
@ -0,0 +1 @@
|
|||
alter table entries add column starred bool default 'f';
|
2
database/sql/schema_version_13.sql
Normal file
2
database/sql/schema_version_13.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
create index entries_user_status_idx on entries(user_id, status);
|
||||
create index feeds_user_category_idx on feeds(user_id, category_id);
|
3
database/sql/schema_version_14.sql
Normal file
3
database/sql/schema_version_14.sql
Normal file
|
@ -0,0 +1,3 @@
|
|||
alter table integrations add column nunux_keeper_enabled bool default 'f';
|
||||
alter table integrations add column nunux_keeper_url text default '';
|
||||
alter table integrations add column nunux_keeper_api_key text default '';
|
1
database/sql/schema_version_15.sql
Normal file
1
database/sql/schema_version_15.sql
Normal file
|
@ -0,0 +1 @@
|
|||
alter table enclosures alter column size set data type bigint;
|
1
database/sql/schema_version_16.sql
Normal file
1
database/sql/schema_version_16.sql
Normal file
|
@ -0,0 +1 @@
|
|||
alter table entries add column comments_url text default '';
|
3
database/sql/schema_version_17.sql
Normal file
3
database/sql/schema_version_17.sql
Normal file
|
@ -0,0 +1,3 @@
|
|||
alter table integrations add column pocket_enabled bool default 'f';
|
||||
alter table integrations add column pocket_access_token text default '';
|
||||
alter table integrations add column pocket_consumer_key text default '';
|
1
database/sql/schema_version_18.sql
Normal file
1
database/sql/schema_version_18.sql
Normal file
|
@ -0,0 +1 @@
|
|||
alter table user_sessions alter column ip set data type inet using ip::inet;
|
2
database/sql/schema_version_19.sql
Normal file
2
database/sql/schema_version_19.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
alter table feeds add column username text default '';
|
||||
alter table feeds add column password text default '';
|
3
database/sql/schema_version_2.sql
Normal file
3
database/sql/schema_version_2.sql
Normal file
|
@ -0,0 +1,3 @@
|
|||
create extension if not exists hstore;
|
||||
alter table users add column extra hstore;
|
||||
create index users_extra_idx on users using gin(extra);
|
3
database/sql/schema_version_20.sql
Normal file
3
database/sql/schema_version_20.sql
Normal file
|
@ -0,0 +1,3 @@
|
|||
alter table entries add column document_vectors tsvector;
|
||||
update entries set document_vectors = to_tsvector(title || ' ' || coalesce(content, ''));
|
||||
create index document_vectors_idx on entries using gin(document_vectors);
|
6
database/sql/schema_version_3.sql
Normal file
6
database/sql/schema_version_3.sql
Normal file
|
@ -0,0 +1,6 @@
|
|||
create table tokens (
|
||||
id text not null,
|
||||
value text not null,
|
||||
created_at timestamp with time zone not null default now(),
|
||||
primary key(id, value)
|
||||
);
|
2
database/sql/schema_version_4.sql
Normal file
2
database/sql/schema_version_4.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
create type entry_sorting_direction as enum('asc', 'desc');
|
||||
alter table users add column entry_direction entry_sorting_direction default 'asc';
|
15
database/sql/schema_version_5.sql
Normal file
15
database/sql/schema_version_5.sql
Normal file
|
@ -0,0 +1,15 @@
|
|||
create table integrations (
|
||||
user_id int not null,
|
||||
pinboard_enabled bool default 'f',
|
||||
pinboard_token text default '',
|
||||
pinboard_tags text default 'miniflux',
|
||||
pinboard_mark_as_unread bool default 'f',
|
||||
instapaper_enabled bool default 'f',
|
||||
instapaper_username text default '',
|
||||
instapaper_password text default '',
|
||||
fever_enabled bool default 'f',
|
||||
fever_username text default '',
|
||||
fever_password text default '',
|
||||
fever_token text default '',
|
||||
primary key(user_id)
|
||||
)
|
1
database/sql/schema_version_6.sql
Normal file
1
database/sql/schema_version_6.sql
Normal file
|
@ -0,0 +1 @@
|
|||
alter table feeds add column scraper_rules text default '';
|
1
database/sql/schema_version_7.sql
Normal file
1
database/sql/schema_version_7.sql
Normal file
|
@ -0,0 +1 @@
|
|||
alter table feeds add column rewrite_rules text default '';
|
1
database/sql/schema_version_8.sql
Normal file
1
database/sql/schema_version_8.sql
Normal file
|
@ -0,0 +1 @@
|
|||
alter table feeds add column crawler boolean default 'f';
|
1
database/sql/schema_version_9.sql
Normal file
1
database/sql/schema_version_9.sql
Normal file
|
@ -0,0 +1 @@
|
|||
alter table sessions rename to user_sessions;
|
Loading…
Add table
Add a link
Reference in a new issue