add composite key on ttrss_feeds (feed_url & owner_uid)

This commit is contained in:
Andrew Dolgov 2019-03-10 15:45:30 +03:00
parent 95e70320a6
commit 32f9fda33d
5 changed files with 21 additions and 5 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
define('EXPECTED_CONFIG_VERSION', 26); define('EXPECTED_CONFIG_VERSION', 26);
define('SCHEMA_VERSION', 136); define('SCHEMA_VERSION', 137);
define('LABEL_BASE_INDEX', -1024); define('LABEL_BASE_INDEX', -1024);
define('PLUGIN_FEED_BASE_INDEX', -128); define('PLUGIN_FEED_BASE_INDEX', -128);

View File

@ -133,7 +133,8 @@ create table ttrss_feeds (id integer not null auto_increment primary key,
feed_language varchar(100) not null default '', feed_language varchar(100) not null default '',
foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE, foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE,
foreign key (cat_id) references ttrss_feed_categories(id) ON DELETE SET NULL, foreign key (cat_id) references ttrss_feed_categories(id) ON DELETE SET NULL,
foreign key (parent_feed) references ttrss_feeds(id) ON DELETE SET NULL) ENGINE=InnoDB DEFAULT CHARSET=UTF8; foreign key (parent_feed) references ttrss_feeds(id) ON DELETE SET NULL,
unique(feed_url(255), owner_uid)) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
insert into ttrss_feeds (owner_uid, title, feed_url) values insert into ttrss_feeds (owner_uid, title, feed_url) values
(1, 'Tiny Tiny RSS: Forum', 'http://tt-rss.org/forum/rss.php'); (1, 'Tiny Tiny RSS: Forum', 'http://tt-rss.org/forum/rss.php');
@ -286,7 +287,7 @@ create table ttrss_tags (id integer primary key auto_increment,
create table ttrss_version (schema_version int not null) ENGINE=InnoDB DEFAULT CHARSET=UTF8; create table ttrss_version (schema_version int not null) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
insert into ttrss_version values (136); insert into ttrss_version values (137);
create table ttrss_enclosures (id integer primary key auto_increment, create table ttrss_enclosures (id integer primary key auto_increment,
content_url text not null, content_url text not null,

View File

@ -99,7 +99,8 @@ create table ttrss_feeds (id serial not null primary key,
pubsub_state integer not null default 0, pubsub_state integer not null default 0,
favicon_last_checked timestamp default null, favicon_last_checked timestamp default null,
feed_language varchar(100) not null default '', feed_language varchar(100) not null default '',
auth_pass_encrypted boolean not null default false); auth_pass_encrypted boolean not null default false,
unique(feed_url, owner_uid));
create index ttrss_feeds_owner_uid_index on ttrss_feeds(owner_uid); create index ttrss_feeds_owner_uid_index on ttrss_feeds(owner_uid);
create index ttrss_feeds_cat_id_idx on ttrss_feeds(cat_id); create index ttrss_feeds_cat_id_idx on ttrss_feeds(cat_id);
@ -268,7 +269,7 @@ create index ttrss_tags_post_int_id_idx on ttrss_tags(post_int_id);
create table ttrss_version (schema_version int not null); create table ttrss_version (schema_version int not null);
insert into ttrss_version values (136); insert into ttrss_version values (137);
create table ttrss_enclosures (id serial not null primary key, create table ttrss_enclosures (id serial not null primary key,
content_url text not null, content_url text not null,

View File

@ -0,0 +1,7 @@
begin;
alter table ttrss_feeds add constraint ttrss_feeds_feed_url_owner_uid_key unique (feed_url(254), owner_uid);
update ttrss_version set schema_version = 137;
commit;

View File

@ -0,0 +1,7 @@
begin;
alter table ttrss_feeds add constraint ttrss_feeds_feed_url_owner_uid_key unique (feed_url, owner_uid);
update ttrss_version set schema_version = 137;
commit;