-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy path007-gallformers.sql
45 lines (38 loc) · 1.18 KB
/
007-gallformers.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
-- Up
PRAGMA foreign_keys=OFF;
-- adding support for image relationships to species-source mappings
-- adding licenselink and lastchangedby fields
CREATE TABLE image__ (
id INTEGER PRIMARY KEY
NOT NULL,
species_id INTEGER NOT NULL,
source_id INTEGER,
path TEXT UNIQUE
NOT NULL,
[default] BOOLEAN DEFAULT FALSE,
creator TEXT,
attribution TEXT,
sourcelink TEXT,
license TEXT,
licenselink TEXT,
uploader TEXT,
lastchangedby TEXT,
FOREIGN KEY (
species_id
)
REFERENCES species (id) ON DELETE CASCADE,
FOREIGN KEY (
source_id
)
REFERENCES source (id) ON DELETE CASCADE
);
INSERT INTO image__ (id, species_id, path, [default], creator, attribution, sourcelink, license, uploader, lastchangedby, species_id)
SELECT id, species_id, path, [default], creator, attribution, source, license, uploader, uploader, species_id
FROM image;
DROP TABLE image;
ALTER TABLE image__ RENAME TO image;
PRAGMA foreign_keys=ON;
--------------------------------------------------------------
-- Down
PRAGMA foreign_keys=OFF;
PRAGMA foreign_keys=ON;