Added tags table
parent
b80a060faf
commit
8284438576
|
@ -4,5 +4,6 @@ drop trigger update_enforce_version_titles on versions;
|
||||||
drop function enforce_version_titles;
|
drop function enforce_version_titles;
|
||||||
|
|
||||||
drop table versions cascade;
|
drop table versions cascade;
|
||||||
|
drop table tags cascade;
|
||||||
drop table posts cascade;
|
drop table posts cascade;
|
||||||
drop table sections cascade;
|
drop table sections cascade;
|
||||||
|
|
|
@ -46,7 +46,14 @@ create table versions (
|
||||||
|
|
||||||
-- This check allows draft posts to be created without having to enter a
|
-- This check allows draft posts to be created without having to enter a
|
||||||
-- publish date, but forces them to have one if they're not a draft.
|
-- publish date, but forces them to have one if they're not a draft.
|
||||||
CHECK (is_draft OR publish_date IS NOT NULL)
|
CONSTRAINT no_null_published_date CHECK (is_draft OR publish_date IS NOT NULL)
|
||||||
|
);
|
||||||
|
|
||||||
|
create table tags (
|
||||||
|
post_id uuid NOT NULL REFERENCES posts(id) ON DELETE CASCADE,
|
||||||
|
value varchar(64) NOT NULL,
|
||||||
|
|
||||||
|
PRIMARY KEY (post_id, value)
|
||||||
);
|
);
|
||||||
|
|
||||||
create function enforce_version_titles() returns trigger as $$
|
create function enforce_version_titles() returns trigger as $$
|
||||||
|
|
|
@ -19,6 +19,13 @@ table! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table! {
|
||||||
|
tags (post_id, value) {
|
||||||
|
post_id -> Uuid,
|
||||||
|
value -> Varchar,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
table! {
|
table! {
|
||||||
versions (id) {
|
versions (id) {
|
||||||
id -> Uuid,
|
id -> Uuid,
|
||||||
|
@ -31,10 +38,12 @@ table! {
|
||||||
}
|
}
|
||||||
|
|
||||||
joinable!(posts -> sections (section_id));
|
joinable!(posts -> sections (section_id));
|
||||||
|
joinable!(tags -> posts (post_id));
|
||||||
joinable!(versions -> posts (post_id));
|
joinable!(versions -> posts (post_id));
|
||||||
|
|
||||||
allow_tables_to_appear_in_same_query!(
|
allow_tables_to_appear_in_same_query!(
|
||||||
posts,
|
posts,
|
||||||
sections,
|
sections,
|
||||||
|
tags,
|
||||||
versions,
|
versions,
|
||||||
);
|
);
|
||||||
|
|
Reference in New Issue