-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow for media cover deletion (#387)
* Allow for media cover deletion Fix #356 * Fix sqlite migrations
- Loading branch information
1 parent
7c8599b
commit aa72334
Showing
4 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
migrations/postgres/2018-12-25-164502_media-cover-deletion/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-- This file should undo anything in `up.sql` | ||
|
||
ALTER TABLE posts DROP CONSTRAINT posts_cover_id_fkey; | ||
ALTER TABLE posts ADD CONSTRAINT posts_cover_id_fkey FOREIGN KEY (cover_id) REFERENCES medias(id); |
4 changes: 4 additions & 0 deletions
4
migrations/postgres/2018-12-25-164502_media-cover-deletion/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-- Your SQL goes here | ||
|
||
ALTER TABLE posts DROP CONSTRAINT posts_cover_id_fkey; | ||
ALTER TABLE posts ADD CONSTRAINT posts_cover_id_fkey FOREIGN KEY (cover_id) REFERENCES medias(id) ON DELETE SET NULL; |
21 changes: 21 additions & 0 deletions
21
migrations/sqlite/2018-12-25-164502_media-cover-deletion/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-- This file should undo anything in `up.sql` | ||
|
||
CREATE TABLE posts2 ( | ||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
blog_id INTEGER REFERENCES blogs(id) ON DELETE CASCADE NOT NULL, | ||
slug VARCHAR NOT NULL, | ||
title VARCHAR NOT NULL, | ||
content TEXT NOT NULL DEFAULT '', | ||
published BOOLEAN NOT NULL DEFAULT 'f', | ||
license VARCHAR NOT NULL DEFAULT 'CC-BY-SA', | ||
creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
ap_url VARCHAR NOT NULL DEFAULT '' UNIQUE, | ||
subtitle TEXT NOT NULL DEFAULT '', | ||
source TEXT NOT NULL DEFAULT '', | ||
cover_id INTEGER REFERENCES medias(id) DEFAULT NULL, | ||
CONSTRAINT blog_authors_unique UNIQUE (blog_id, slug) | ||
); | ||
|
||
INSERT INTO posts2 SELECT * from posts; | ||
DROP TABLE posts; | ||
ALTER TABLE posts2 RENAME TO posts; |
21 changes: 21 additions & 0 deletions
21
migrations/sqlite/2018-12-25-164502_media-cover-deletion/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-- Your SQL goes here | ||
|
||
CREATE TABLE posts2 ( | ||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
blog_id INTEGER REFERENCES blogs(id) ON DELETE CASCADE NOT NULL, | ||
slug VARCHAR NOT NULL, | ||
title VARCHAR NOT NULL, | ||
content TEXT NOT NULL DEFAULT '', | ||
published BOOLEAN NOT NULL DEFAULT 'f', | ||
license VARCHAR NOT NULL DEFAULT 'CC-BY-SA', | ||
creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
ap_url VARCHAR NOT NULL DEFAULT '' UNIQUE, | ||
subtitle TEXT NOT NULL DEFAULT '', | ||
source TEXT NOT NULL DEFAULT '', | ||
cover_id INTEGER REFERENCES medias(id) ON DELETE SET NULL DEFAULT NULL, | ||
CONSTRAINT blog_authors_unique UNIQUE (blog_id, slug) | ||
); | ||
|
||
INSERT INTO posts2 SELECT * from posts; | ||
DROP TABLE posts; | ||
ALTER TABLE posts2 RENAME TO posts; |