change mime_types schema
This commit is contained in:
parent
f7a6fba366
commit
d9e7a87a01
10
atom
10
atom
@ -521,16 +521,16 @@ getFiles() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateMimes() {
|
updateMimes() {
|
||||||
Update mime_types action 1 <<<"action != 1"
|
Update mime_actions action 1 <<<"action != 1"
|
||||||
for destination in ${!destinationskipmime[@]}
|
for destination in ${!destinationskipmime[@]}
|
||||||
do
|
do
|
||||||
IFS='|'
|
IFS='|'
|
||||||
for mime_type in ${destinationskipmime["$destination"]}
|
for mime_type in ${destinationskipmime["$destination"]}
|
||||||
do
|
do
|
||||||
IFS="$oldIFS"
|
IFS="$oldIFS"
|
||||||
Update mime_types action 0 >/dev/null < <(
|
Update mime_type_actions action 0 >/dev/null < <(
|
||||||
cat <<-EOWhere
|
cat <<-EOWhere
|
||||||
destination_id ${destinationid["$destination"]}
|
destination_id = ${destinationid["$destination"]}
|
||||||
mime_text LIKE ${mime_type//*/%}
|
mime_text LIKE ${mime_type//*/%}
|
||||||
EOWhere
|
EOWhere
|
||||||
)
|
)
|
||||||
@ -542,9 +542,9 @@ updateMimes() {
|
|||||||
for mime_type in ${destinationcopymime["$destination"]}
|
for mime_type in ${destinationcopymime["$destination"]}
|
||||||
do
|
do
|
||||||
IFS="$oldIFS"
|
IFS="$oldIFS"
|
||||||
Update mime_types action 2 >/dev/null < <(
|
Update mime_type_actions action 2 >/dev/null < <(
|
||||||
cat <<-EOWhere
|
cat <<-EOWhere
|
||||||
destination_id ${destinationid["$destination"]}
|
destination_id = ${destinationid["$destination"]}
|
||||||
mime_text LIKE ${mime_type//*/%}
|
mime_text LIKE ${mime_type//*/%}
|
||||||
EOWhere
|
EOWhere
|
||||||
)
|
)
|
||||||
|
|||||||
@ -24,12 +24,36 @@ CREATE TABLE destination_files (
|
|||||||
);
|
);
|
||||||
CREATE TABLE mime_types (
|
CREATE TABLE mime_types (
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
|
mime_text TEXT UNIQUE NOT NULL
|
||||||
|
);
|
||||||
|
CREATE TABLE mime_actions (
|
||||||
|
id INTEGER PRIMARY KEY,
|
||||||
|
mime_type INTEGER,
|
||||||
destination_id INTEGER,
|
destination_id INTEGER,
|
||||||
mime_text TEXT UNIQUE NOT NULL,
|
|
||||||
action INTEGER DEFAULT 1,
|
action INTEGER DEFAULT 1,
|
||||||
|
FOREIGN KEY (mime_type) REFERENCES mime_types(id)
|
||||||
FOREIGN KEY (destination_id) REFERENCES destinations(id)
|
FOREIGN KEY (destination_id) REFERENCES destinations(id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE VIEW mime_type_actions AS
|
||||||
|
SELECT
|
||||||
|
mime_types.id,mime_types.mime_text,
|
||||||
|
mime_actions.destination_id,mime_actions.action
|
||||||
|
FROM mime_types INNER JOIN mime_actions
|
||||||
|
ON mime_actions.mime_type = mime_types.id;
|
||||||
|
CREATE TRIGGER update_mime_actions INSTEAD OF UPDATE OF action ON mime_type_actions
|
||||||
|
BEGIN
|
||||||
|
UPDATE mime_actions SET action=new.action WHERE mime_type=old.id;
|
||||||
|
END;
|
||||||
|
|
||||||
|
CREATE TRIGGER create_mime_actions AFTER INSERT ON mime_types
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO mime_actions (mime_type,destination_id)
|
||||||
|
SELECT mime_types.id,destinations.id
|
||||||
|
FROM mime_types INNER JOIN destinations
|
||||||
|
WHERE mime_types.id=new.id;
|
||||||
|
END;
|
||||||
|
|
||||||
CREATE INDEX sourcefiles_by_name ON source_files (filename,id);
|
CREATE INDEX sourcefiles_by_name ON source_files (filename,id);
|
||||||
|
|
||||||
CREATE TRIGGER create_destinations AFTER INSERT ON source_files
|
CREATE TRIGGER create_destinations AFTER INSERT ON source_files
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user