aboutsummaryrefslogtreecommitdiff
path: root/src/guff/database-updater.cr
diff options
context:
space:
mode:
Diffstat (limited to 'src/guff/database-updater.cr')
-rw-r--r--src/guff/database-updater.cr16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/guff/database-updater.cr b/src/guff/database-updater.cr
index c1d4188..daf77fd 100644
--- a/src/guff/database-updater.cr
+++ b/src/guff/database-updater.cr
@@ -86,7 +86,7 @@ module Guff
CREATE INDEX in_posts_slug ON posts(slug)
}],
}, {
- id: "2-create-indices",
+ id: "2-create-tags",
backup: false,
sql: [%{
@@ -96,6 +96,20 @@ module Guff
)
}, %{
CREATE INDEX in_tags_name ON tags(name)
+ }, %{
+ CREATE TABLE post_tags (
+ tag_id INTEGER NOT NULL
+ REFERENCES tags(tag_id),
+
+ post_id INTEGER NOT NULL
+ REFERENCES posts(post_id),
+
+ UNIQUE(tag_id, post_id)
+ )
+ }, %{
+ CREATE INDEX in_post_tags_tag_id ON post_tags(tag_id)
+ }, %{
+ CREATE INDEX in_post_tags_post_id ON post_tags(post_id)
}],
}, {
id: "3-create-domains",