aboutsummaryrefslogtreecommitdiffstats
path: root/migrations/001_migrate_news_images_to_multi.sql
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2025-11-28 22:46:28 -0500
committerPinapelz <yukais@pinapelz.com>2025-11-28 22:46:28 -0500
commit7681e421edb3933c8727cb0936bc8310d79df6e2 (patch)
tree6f74c9ea471b6820c23bcb1694079a250d09510d /migrations/001_migrate_news_images_to_multi.sql
parentde4a37b4cdb4cd752c4ce2361912fa2bb84cc766 (diff)
fix: change news image table to handle multiple images for each post
Diffstat (limited to 'migrations/001_migrate_news_images_to_multi.sql')
-rw-r--r--migrations/001_migrate_news_images_to_multi.sql14
1 files changed, 14 insertions, 0 deletions
diff --git a/migrations/001_migrate_news_images_to_multi.sql b/migrations/001_migrate_news_images_to_multi.sql
new file mode 100644
index 0000000..beb4b05
--- /dev/null
+++ b/migrations/001_migrate_news_images_to_multi.sql
@@ -0,0 +1,14 @@
+-- migrates old news image table from single images to multi per news
+PRAGMA foreign_keys = OFF;
+CREATE TABLE news_images_new (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ news_id VARCHAR(255) NOT NULL,
+ image_url TEXT NOT NULL,
+ link_url TEXT,
+ FOREIGN KEY (news_id) REFERENCES news(news_id) ON DELETE CASCADE
+);
+INSERT INTO news_images_new (news_id, image_url, link_url)
+SELECT news_id, image_url, link_url FROM news_images;
+DROP TABLE news_images;
+ALTER TABLE news_images_new RENAME TO news_images;
+PRAGMA foreign_keys = ON;
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage