CREATE TABLE movie (
idMovie integer PRIMARY KEY AUTOINCREMENT,
idSource integer NOT NULL,
MoviePath text,
Type bool,
HasSub bool NOT NULL DEFAULT 0,
"New" bool NOT NULL DEFAULT 0,
Mark bool NOT NULL DEFAULT 0,
Imdb text,
Lock bool,
Title text,
OriginalTitle text,
Year text,
Rating text,
Votes text,
MPAA text,
Top250 integer,
Outline text,
Plot text,
Tagline text,
Certification text,
Runtime text,
premiered text,
Playcount integer,
Trailer text,
EThumbsPath text,
NfoPath text,
TrailerPath text,
SubPath text,
FanartURL text,
OutOfTolerance bool,
VideoSource text,
SortTitle text,
DateAdded integer,
EFanartsPath text,
ThemePath text,
TMDB text,
TMDBColID text,
DateModified integer,
MarkCustom1 bool NOT NULL DEFAULT 0,
MarkCustom2 bool NOT NULL DEFAULT 0,
MarkCustom3 bool NOT NULL DEFAULT 0,
MarkCustom4 bool NOT NULL DEFAULT 0,
HasSet bool NOT NULL DEFAULT 0,
iLastPlayed integer,
Language text,
iUserRating integer NOT NULL DEFAULT 0,
userNote text,
edition text
);
CREATE TRIGGER delete_movie
AFTER DELETE
ON movie
BEGIN
DELETE FROM actorlinkmovie WHERE idMovie=old.idMovie;
DELETE FROM art WHERE media_id=old.idMovie AND media_type='movie';
DELETE FROM countrylinkmovie WHERE idMovie=old.idMovie;
DELETE FROM directorlinkmovie WHERE idMovie=old.idMovie;
DELETE FROM genrelinkmovie WHERE idMovie=old.idMovie;
DELETE FROM movielinktvshow WHERE idMovie=old.idMovie;
DELETE FROM rating WHERE media_id=old.idMovie AND media_type='movie';
DELETE FROM setlinkmovie WHERE idMovie=old.idMovie;
DELETE FROM studiolinkmovie WHERE idMovie=old.idMovie;
DELETE FROM taglinks WHERE idMedia=old.idMovie AND media_type='movie';
DELETE FROM uniqueid WHERE media_id=old.idMovie AND media_type='movie';
DELETE FROM writerlinkmovie WHERE idMovie=old.idMovie;
DELETE FROM MoviesAStreams WHERE MovieID=old.idMovie;
DELETE FROM MoviesSubs WHERE MovieID=old.idMovie;
DELETE FROM MoviesVStreams WHERE MovieID=old.idMovie;
END;