feat: mentions in lives_with and text_body fields
Some checks failed
/ integration-test--firefox (push) Failing after 3m7s
Some checks failed
/ integration-test--firefox (push) Failing after 3m7s
This commit is contained in:
parent
fd5f1899c1
commit
d42adbe274
10 changed files with 369 additions and 200 deletions
|
|
@ -30,17 +30,18 @@ insert into names(contact_id, sort, name) values
|
|||
(3, 0, 'Eleanor Edgeworth'),
|
||||
(3, 1, 'Eleanor');
|
||||
|
||||
insert into contacts(id, lives_with) values (4, 'Henrietta');
|
||||
insert into contacts(id, lives_with) values (4, '[[Henrietta]]');
|
||||
insert into names(contact_id, sort, name) values
|
||||
(4, 0, 'Felicia Homeowner');
|
||||
|
||||
insert into contacts(id, lives_with) values (5, 'Henrietta');
|
||||
insert into contacts(id, lives_with) values (5, '[[Henrietta]]');
|
||||
insert into names(contact_id, sort, name) values
|
||||
(5, 0, 'Gregory Homeowner');
|
||||
|
||||
insert into contacts(id) values (6);
|
||||
insert into names(contact_id, sort, name) values
|
||||
(6, 0, 'Henrietta Homeowner');
|
||||
(6, 0, 'Henrietta Homeowner'),
|
||||
(6, 1, 'Henrietta');
|
||||
|
||||
insert into addresses(contact_id, label, value) values
|
||||
(6, null, '123 Main St., Realville, WI 99999');
|
||||
|
|
@ -53,13 +54,13 @@ insert into journal_entries(id, date, value) values
|
|||
(4, '2024-02-17', 'Friendship ended with [[Bazel]]. Now [[Eleanor Edgeworth]] is my best friend.'),
|
||||
(5, '2024-02-18', 'With [[Bazel]] gone, dissolved [[ABC]] Corp. Start discussions for a potential ACE, Inc. with [[Alexi]] and [[Eleanor]].');
|
||||
|
||||
insert into journal_mentions values
|
||||
(0, 'Bazel Bagend', 11, 27, '/contact/1'),
|
||||
(1, 'Alexi', 12, 21, '/contact/0'),
|
||||
(3, 'ABC', 24, 31, '/group/ABC'),
|
||||
(4, 'Bazel', 22, 31, '/contact/1'),
|
||||
(4, 'Eleanor Edgeworth', 37, 58, '/contact/3'),
|
||||
(5, 'Eleanor', 108, 119, '/contact/3'),
|
||||
(5, 'Alexi', 94, 103, '/contact/0'),
|
||||
(5, 'Bazel', 5, 14, '/contact/1'),
|
||||
(5, 'ABC', 31, 38, '/group/ABC');
|
||||
insert into mentions (entity_id, entity_type, input_text, byte_range_start, byte_range_end, url) values
|
||||
(0, 'journal_entry', 'Bazel Bagend', 11, 27, '/contact/1'),
|
||||
(1, 'journal_entry', 'Alexi', 12, 21, '/contact/0'),
|
||||
(3, 'journal_entry', 'ABC', 24, 31, '/group/ABC'),
|
||||
(4, 'journal_entry', 'Bazel', 22, 31, '/contact/1'),
|
||||
(4, 'journal_entry', 'Eleanor Edgeworth', 37, 58, '/contact/3'),
|
||||
(5, 'journal_entry', 'Eleanor', 108, 119, '/contact/3'),
|
||||
(5, 'journal_entry', 'Alexi', 94, 103, '/contact/0'),
|
||||
(5, 'journal_entry', 'Bazel', 5, 14, '/contact/1'),
|
||||
(5, 'journal_entry', 'ABC', 31, 38, '/group/ABC');
|
||||
|
|
|
|||
30
migrations/each_user/0010_more-mentions.sql
Normal file
30
migrations/each_user/0010_more-mentions.sql
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
create table if not exists mentions (
|
||||
entity_id integer not null,
|
||||
entity_type integer not null,
|
||||
url text not null,
|
||||
input_text text not null,
|
||||
byte_range_start integer not null,
|
||||
byte_range_end integer not null
|
||||
);
|
||||
|
||||
insert into mentions (
|
||||
entity_id, url, input_text, byte_range_start, byte_range_end, entity_type)
|
||||
select entry_id, url, input_text, byte_range_start, byte_range_end, 'journal_entry'
|
||||
from journal_mentions;
|
||||
|
||||
drop table journal_mentions;
|
||||
|
||||
-- entity types:
|
||||
-- 0: journal_entry
|
||||
-- 1: contact.text_body
|
||||
-- 2: contact.lives_with
|
||||
create trigger if not exists cascade_delete_journal_mentions
|
||||
after delete on journal_entries for each row begin
|
||||
delete from mentions where entity_type = 0 and entity_id = OLD.id;
|
||||
end;
|
||||
|
||||
create trigger if not exists cascade_delete_contact_text_body_mentions
|
||||
after delete on contacts for each row begin
|
||||
delete from mentions where entity_type = 1 and entity_id = OLD.id;
|
||||
delete from mentions where entity_type = 2 and entity_id = OLD.id;
|
||||
end;
|
||||
Loading…
Add table
Add a link
Reference in a new issue