aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMasaya Tojo <masaya@tojo.tokyo>2024-03-16 03:02:02 +0900
committerMasaya Tojo <masaya@tojo.tokyo>2024-03-16 03:02:02 +0900
commit2fb413587fc1d34045a8724b0aac60e8e8051560 (patch)
treed590f83c650e8bca7b0d4bf28e7b692f25bd531a
parenta86f747e0db4bde6bc598a5ade8949cd8b3a4b3f (diff)
Add table for tagging articles.
-rw-r--r--deploy/article_taggings.sql16
-rw-r--r--revert/article_taggings.sql9
-rw-r--r--sqitch.plan1
-rw-r--r--verify/article_taggings.sql11
4 files changed, 37 insertions, 0 deletions
diff --git a/deploy/article_taggings.sql b/deploy/article_taggings.sql
new file mode 100644
index 0000000..3985543
--- /dev/null
+++ b/deploy/article_taggings.sql
@@ -0,0 +1,16 @@
+-- Deploy diary:article_taggings to pg
+-- requires: schema
+-- requires: tags
+-- requires: articles
+
+BEGIN;
+
+SET search_path to diary;
+
+CREATE TABLE article_taggings(
+ article_id UUID REFERENCES articles(id),
+ tag_id INT REFERENCES tags(id),
+ PRIMARY KEY(article_id, tag_id)
+);
+
+COMMIT;
diff --git a/revert/article_taggings.sql b/revert/article_taggings.sql
new file mode 100644
index 0000000..6f0d57c
--- /dev/null
+++ b/revert/article_taggings.sql
@@ -0,0 +1,9 @@
+-- Revert diary:article_taggings from pg
+
+BEGIN;
+
+SET search_path to diary;
+
+DROP TABLE article_taggings;
+
+COMMIT;
diff --git a/sqitch.plan b/sqitch.plan
index 71228b4..c500b49 100644
--- a/sqitch.plan
+++ b/sqitch.plan
@@ -5,3 +5,4 @@
schema 2024-03-10T11:00:19Z Masaya Tojo <masaya@tojo.tokyo> # Add schema for diary objects.
articles [schema] 2024-03-10T13:54:19Z Masaya Tojo <masaya@tojo.tokyo> # Add table manage diary articles.
tags [schema] 2024-03-10T15:55:56Z Masaya Tojo <masaya@tojo.tokyo> # Add table manage diary tags.
+article_taggings [schema tags articles] 2024-03-15T17:54:50Z Masaya Tojo <masaya@tojo.tokyo> # Add table for tagging articles.
diff --git a/verify/article_taggings.sql b/verify/article_taggings.sql
new file mode 100644
index 0000000..9947337
--- /dev/null
+++ b/verify/article_taggings.sql
@@ -0,0 +1,11 @@
+-- Verify diary:article_taggings on pg
+
+BEGIN;
+
+SET search_path to diary;
+
+SELECT article_id, tag_id
+ FROM article_taggings
+ WHERE FALSE;
+
+ROLLBACK;