aboutsummaryrefslogtreecommitdiffstats
path: root/migrations/001_migrate_news_images_to_multi.sql
blob: beb4b051015878e52dd3bf2df2c9dab2c2e80b05 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
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